?
Solved

Popup menu from taskbar icon

Posted on 1999-11-11
5
Medium Priority
?
407 Views
Last Modified: 2013-12-03
My program does the following when the user clicks the program's icon in the taskbar's tray area:

hMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING, ID1, "Title1");
// ..........
AppendMenu(hMenu, MF_STRING, ID16, "Title16");

GetCursorPos(&pt);
SetForegroundWindow(g_hwndMain);
TrackPopupMenu(hMenu,
                    TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
                                                         pt.x, pt.y, 0, g_hwndMain, 0);
DestroyMenu(hMenu);
SendMessage(g_hwndMain, 0, 0, 0);

The popup menu hides after I click somewhere outside the menu, but it doesn't appeat next time I click the icon. Only on second or third time.
What should I do to correct this ?
0
Comment
Question by:shvetsov
  • 2
  • 2
5 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 2201254
Try PostMessage(g_hwndMain, WM_NULL, 0, 0) right after TrackPopupMenu and before DestroyMenu. Remove SendMessage(g_hwndMain, 0, 0, 0);.
0
 
LVL 1

Expert Comment

by:AndreasF
ID: 2202314
My taskbarmenu is called exactly as yours is. The only difference: I don't have this SendMessage(...) at all. What is it for?
0
 

Author Comment

by:shvetsov
ID: 2202385
4 chensu: Yes !!! It works. Thank you.
Please mark your comment as answer so I can grade it.

4 AndreasF: It must be PostMessage();
The popup menu doesnt pop up after the first click on the taskbar icon without it. I don't know why. Ask Bill Gates :)
0
 
LVL 23

Accepted Solution

by:
chensu earned 400 total points
ID: 2203732
>What is it for?

PRB: Menus for Notification Icons Do Not Work Correctly
http://support.microsoft.com/support/kb/articles/Q135/7/88.asp
0
 

Author Comment

by:shvetsov
ID: 2204333
Hey! AndreasF and chensu! It's my question! :)
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…
Suggested Courses

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question