Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

Join Tek-Tips
*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.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

popseven (TechnicalUser) (OP)
10 Aug 06 10:53
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
bledazemi (Programmer)
10 Aug 06 16:57
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.

Helpful Member!  buho (Programmer)
10 Aug 06 19:37
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).


 

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