Delphi DLL / Form communication -


I have embedded a form in DLL and can call DLL and show the form and back from DLL Can return different functions. The main app, though I do not understand how to get DLL to trigger events in main applications.

For example, in the main app, I have a dataset and I want to place a certain record in dataset with a button on the form in DLL, but can not see how it can be done.

Can anyone tell me about an example or how do I give some indication on this?

If a DLL needs to initiate a behavior in the host application, then host callback The function should be given to DLL, which is the DLL store and the call is appropriate.

Your DLL exportes the function that asks to display this form, is not it? To provide a pointer in the callback function, add some parameters for that function to EXE. The callback function must accept at least one parameter, which should be of type Pointer . The caller (EXE) will use that parameter as the reference parameter , it can be reminded for why DLL is calling the XE function, your DLL will store the function pointer and reference pointers. , And when the time comes to tell the DLL anything to the EXE, then it will call that function and pass the reference value back. DLL will do nothing with reference value; This is just something that stores and passes the Xi verbatim.

DLL's interface will look like this:

  type TDllCallback = function (context: Pointer): DWord; Stdcall; Function DisplayForm (Parent: hwnd; callback: tdlaclaback; context: indicator): D word; Stdcall; External DLL;  

The EXE will define a callback function like this:

  function callback function (reference: indicator): deedord; Stdcall; Start TMainForm (Something). Results: = 0; End;  

This will call the DLL function in this way:

  Process TMainForm.DoDllTaskClick (Sender: Tubect); Start the display form (handle, callback function, pointer (self)); End;  

Note that the signature of the pre-defined sign with the callback function of the TDllcallback Teys use both stdcall calling conferences, and they are both standalone functions , methods are not methods to avoid methods, because method indicators are special for Delphi, and you use your DLL only by the Delphi host There should be no need to do so, if possible.


Comments