DelphiFAQ Home Search:

TScreen

 

comments6 comments. Current rating: 5 stars (3 votes). Leave comments and/ or rate it.

Each DLL in Delphi maintains its own instance of Application & Screen,
your DLL-calling application should send the its own Application and Screen values to the DLL. The DLL should save and restore its original values.

You should put this code somewhere in your DLL and call the Init() function from your application:

const
  SavedApplication : TApplication = nil;
  SavedScreen : TScreen = nil;

// export this procedure and call it after loading the DLL
procedure Init(anApplicationHandle, aScreenHandle: LongWord);
begin
  if not Assigned(SavedApplication) then
  begin
    SavedApplication := Application;
    Application := TApplication(anApplicationHandle);
  end;

  if not Assigned(SavedScreen) then
  begin
    // ....same...
  end;
end;

initialization

finalization
  if Assigned(SavedApplication) then
  begin
    Application := SavedApplication;
  end;

  if Assigned(SavedScreen) then
  begin
    // ....same.....
  end;
end.

Content-type: text/html

Comments:

2006-10-04, 01:50:39
anonymous from United States  
rating
Helps us geeks to build plugins
2006-12-16, 03:09:26
anonymous from China  
Thanks
2007-11-26, 09:21:30
samdhunt@comcast.net from United States  
rating
My DLL errors on the reference to TApplication in the second line of your example.

const
SavedApplication : TApplication = nil;
SavedScreen : TScreen = nil;

I have tried several code examples using TApplication in my DLL and they all error.

I'd like to be able to create a form contained in a DLL from my EXE and set some form properties. I have succeeded in creating the form, but cannot set form properties because (from what I have read) my EXE and DLL don't share the same TApplication and TScreen.

Help!

Sam Hunt
Auburn, WA USA
2008-03-31, 16:45:34   (updated: 2008-03-31, 16:48:15)
anonymous  
const
SavedApplication : TApplication = nil;
SavedScreen : TScreen = nil;

You can't assign a value to a constant variable like this.

Also ...

SavedApplication := Application;

won't work cause it's declared as constant.
2009-10-01, 06:59:03
anonymous from Italy  
rating
Thank you for explanation
2012-11-12, 05:13:30
anonymous from United States  

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: