Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling DLLs from Delphi

Status
Not open for further replies.

ManojKG

Programmer
Sep 30, 2002
6
0
0
IN
I am having some Delphi compiled DLLs, and i am calling them in my application using Loadlibrary() function and the procedures using getproaddress().

Now the problem is while opening a form in the DLL through exe, a new instance are created and showing that in the tast bar.

I want the form to be displayed in the same handler of exe.

please give me a small example to call DLLs in delphi in proper way.


Manoj
 
Here's an example of a function exported from DLL that calls a form in this DLL. Note that DLL has it's own Application.Handle, so i substitute it with a handle of a calling application:
Code:
function MainForm(Params : Pointer):Boolean;stdcall;
var
  ADllForm     : TfrTest;
  OldHandle    : THandle;
begin
  OldHandle := Application.Handle;
  // TPlugInParams is my type. It's a record, one of it's 
  //fields contains the handle of the main app.
  Application.Handle := TPlugInParams(Params^).AppHandle;
  ADllForm := TfrTest.Create(Application);
  try
    Result := (ADllForm.ShowModal = mrOk);
  finally
    // Restoring old handle;
    Application.Handle := OldHandle; 
    ADllForm.Release;
  end;
end;
Hope that helps.

--- markus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top