Taskbar icon’s popup menu
Posted on 1998-09-18
My application has an icon in the Taskbar Notification Area (but has no visible windows!). Clicking on this icon, a popup menu appears, which has a submenu with dinamically created items. There are several problems:
1. Sometimes, clicking on the icon the popup menu appears but disappears imediatelly.
2. Clicking out of the popup menu, sometimes the popup menu doesn’t disappear.
3. Clicking on the dinamically created submenu items, a protection fault error occurs.
I realized that the first two problems are in connection with the focused window, so I tried to resolve them by showing the main form while the popup menu appears (note that the form will not appear on the screen, because its Top property will be -10000):
procedure TFMail.OnNotifyIcon(var Message: TMessage);
if Message.LParam=WM_RBUTTONDOWN then
if not(Visible) then Show;
Suprizing, this method resolved the protection fault problem, but if I run the program as an exe file (not from Delphi), the first two problems appears.
Has anybody an idea why the protection fault occurs, and how can I resolve this problem in an elegant way?