Popup menu from taskbar icon

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");

                                                         pt.x, pt.y, 0, g_hwndMain, 0);
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 ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try PostMessage(g_hwndMain, WM_NULL, 0, 0) right after TrackPopupMenu and before DestroyMenu. Remove SendMessage(g_hwndMain, 0, 0, 0);.
My taskbarmenu is called exactly as yours is. The only difference: I don't have this SendMessage(...) at all. What is it for?
shvetsovAuthor Commented:
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 :)
>What is it for?

PRB: Menus for Notification Icons Do Not Work Correctly

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shvetsovAuthor Commented:
Hey! AndreasF and chensu! It's my question! :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.