Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Displaying a DLL Form as non modal

Displaying a DLL Form as non modal

Displaying a DLL Form as non modal

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;
    MyDLLForm := TMyDLLForm.Create(sServName, sDBName, sUID, sPW, Application);

  CallDLL name 'CallDLL';


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)?


RE: Displaying a DLL Form as non modal

Hi PopSeven,

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


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.

RE: Displaying a DLL Form as non modal

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).


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close