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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying a DLL Form as non modal 1

Status
Not open for further replies.

popseven

Technical User
Apr 4, 2006
17
0
0
PH
Hi Guys,

Given a DLL and a calling application (.EXE), clicking on a button found
on the calling application will then call the dll and display the form as non modal.
How will I do this that if I switch back to the calling application (which makes the DLL now move to the back of the calling application) and click again the button
to call the dll that it will not create an instance of the form (DLL) but rather just make DLL on top again.
It will be like this until I click the close button found on the DLL form.

Currently, I have a coding somewhat like this on my export function on the DLL.

library MyDLL;
:
:
:
function CallDLL(sServName: string; sDBName: string; sUID: string; sPW: string): Integer; export;
begin
try
MyDLLForm := TMyDLLForm.Create(sServName, sDBName, sUID, sPW, Application);
MyDLLForm.Show;
finally
MyDLLForm.Free;
end;
end;
:
:
:
exports

CallDLL name 'CallDLL';

begin
end.

Upon running the above coding, it seems the form will be freed by doing so. The form will just flash/flick.


Can anybody suggest a Delphi 6 coding (both on the dll and the calling application)
to do this and the properties I need to set (if there is)?

TIA,
popseven
 
Hi PopSeven,

If your program is running in Windows I think may need to mark your CallDLL to be stdcall.

Code:
function CallDLL(sServName: string; sDBName: string; sUID: string; sPW: string): Integer; stdcall;

Also as far as I know the global Application variable you use in your VCL applications will not be the same as the one existing in your DLL. So you may need to pass the Application variable to your DLL.

Finally have you added "Uses ShareMem" as the first in your uses list of the library?

Hope this helps you a little.

 
1) General: check the 'net for discussions about creating form in DLLs, it is tricky; otherwise use packages.

2) stdcall: if you are calling your DLL only from Delphi you have no need for stdcall.

3) Your code: can't understand it. You are using non-modal show and freeing the form in the next line... really it works?

4) Your question:
4.1) Add another dll function to get the form handle.
4.2) Have a variable to store the handle.
4.3) When clicking the button, check your variable
4.3.1) If it is zero, call the DLL to create the form and call the function to get the handle, store it in the var.
4.3.2) If it is non-zero, send a message to the form to get it on top.
4.4) Put your var to zero after freeing the form.

buho (A).


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top