Access violation exception when modifying tray icon!
Posted on 2003-03-29
I have a problem when modifying my tray icon! The strange thing is, that it works at some point in my program, but at another point excatly the same code fragment does not work!!!
Another thing is, that it does work in Delphi 3, but not in Delphi 7!
The exception is: Access viloation at address ... Write of address ...
It appears when excecuting the following code (the exception does not appear when removing this code):
tnid.hIcon := Icon.Handle;
There is an ImageList with a icon at index 1. I can read the icon at a different point of my program.
The icon is initialized with:
HMainIcon := LoadIcon(MainInstance, 'MAINICON');
tnid.cbSize := sizeof(TNotifyIconData);
tnid.Wnd := handle;
tnid.uID := 123;
tnid.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
tnid.uCallbackMessage := WM_NOTIFYICON;
tnid.hIcon := HMainIcon;
Thanks for your help!