简体   繁体   中英

How to use the application icon for forms loaded from Delphi DLL

I have multiple Windows host applications and a DLL that are all created with Delphi. The DLL contains some (modal) dialog forms that are displayed on demand. I already pass the Forms.Application.Handle from the currently running host application to the DLL to get the right windows ownership. Unfortunately the dialog created from DLL still shows a generic icon instead of using the main application icon like done for dialogs that are created directly in the host application.

How can I get tForm based dialogs opened from DLLs to use the current application icon from the host executable instead of a generic Windows icon?

Apparently the host application icon can be handled to the DLL by passing the Forms.Application.Icon.Handle handle value to the library and assign it to the tApplication instance there.

Dummy library code:

procedure MyLib_SetAppIcon( Icon : hIcon ); stdcall;
begin
   if (Icon > 0) then
      Forms.Application.Icon.Handle := Icon;
end;

Dummy host code:

procedure MyLib_SetAppIcon( Icon : hIcon ); stdcall; external 'MyLib.dll';

// ...
MyLib_SetAppIcon(Forms.Application.Icon.Handle);
// ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM