Delphi DLL / Contact Form

I have embedded the form in a DLL and I can call the DLL and show the form and return the various functions from the DLL back to the main application, however I cannot figure out how to get the DLL to fire events in the main applications of the form.

For example, in the main application, I have a data set, and I want to have a button in the form in the DLL to go to a specific record in the data set, but I can’t understand how this is done.

Can someone give me an example or give me some directions on how to do this?

+3
source share
2 answers

DLL , DLL, DLL , .

DLL , , , ? , EXE . , Pointer. (EXE) , , DLL EXE. DLL , , DLL EXE -, . DLL ; -, EXE .

DLL :

type
  TDllCallback = function(Context: Pointer): DWord; stdcall;

function DisplayForm(Parent: HWnd; Callback: TDllCallback; Context: Pointer): DWord; stdcall; external Dll;

EXE :

function CallbackFunction(Context: Pointer): DWord; stdcall;
begin
  TMainForm(Context).DoSomething;
  Result := 0;
end;

DLL :

procedure TMainForm.DoDllTaskClick(Sender: TObject);
begin
  DisplayForm(Handle, CallbackFunction, Pointer(Self));
end;

, CallbackFunction TDllcallback, . stdcall, , . , Delphi, , DLL Delphi, .

+9

DLL- , .

  • DLL.
  • DLL - .
  • .
+2

Source: https://habr.com/ru/post/1766824/


All Articles