Why is my icon ugly on the tray bar with TTrayIcon?
You state that you are not assigning the icon. In which case the component uses Application.Icon
. But that will typically be an icon that is the wrong size for the notification area.
For the notification area you need to use a square icon with size determined by the SM_CXSMICON
system metric. The best way to get that is to call LoadImage
which allows you to specify the icon size. Once you have loaded the icon into an HICON
you can just write this:
AppTrayIcon.Icon.Handle := IconHandle;
You don't have the proper size or color depth for your icon.
You can use an icon editor to provide multiple size and color depth icons to a single .ico
file, and Windows will automatically choose the proper one based on the user's settings and video driver configuration. Windows will then have several choices to use when selecting the closest match, and the scaling and blending will have a much better appearance.
I use GreenFish Icon Editor, which is donation-ware. It will allow you to open any supported graphic type and then create a Windows icon with multiple color depths and resolutions automatically from it (see the Icon
menu). I've tested the multi-image icon files in Delphi 7, 2007, 2010, XE, and XE3, and they work fine for the Application.Icon
and TForm.Icon
.
Also see Best Icon size for displaying in the tray