Question

I change the icon of my application with my own icon (32x32 16bit EGA) using :

Project > Option > Applications > Load Icon

The Icon within the taskbar changed very well in many Border Style := bsNone or bsSingle or bsSizeable or bsSizeToolWin or bsToolWindow. But the icon did not change while I use BorderStyle := bsDialog.

Please do not tell me to use :

Application.Icon.LoadFromFile(extractfilepath(application.exename) + '\myicon.ico');

Becase I want to submit one EXE file only.

PS: I use Embarcadero Delphi 2010

Était-ce utile?

La solution

The icon is that of the window associated with the taskbar button. So with Application.MainFormOnTaskbar set to True, it's the main form icon. When False it's the icon of the hidden window of Application. So to have different icon on taskbar from main form, you need MainFormOnTaskbar to be False, and assign different icon to Application.Icon. This seems to be the easy way to work around the issue.

If I recall the VCL only sets one size of icon. In my experience it is better to do the job properly yourself and send WM_SETICON messages directly to set both small and large icons.

As for where your icons reside, link them to your executable as resources. I avoid image lists because I lose control of the raw .ico files, but that's perhaps just me being picky. Feel free to use image lists if you like.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top