The Below code is to create an popup menu on system tray Icon
VOID DisplayMenu(HWND hWnd)
{
HMENU hMenu ;
POINT pCursor;
hMenu = LoadMenu(hInst,MAKEINTRESOURCE(IDC_GETSCREEN));
GetCursorPos(&pCursor);
TrackPopupMenu(hMenu, TPM_BOTTOMALIGN | TPM_LEFTBUTTON | TPM_NOANIMATION, pCursor.x, pCursor.y, 0, hWnd, NULL);
}
this function is being called on click on the system tray menu
IDC_GETSCREEN is a menu resource ID the lay out is given below:
________ __________
|File | | Help |
-------- ----------
|Exit | |About |
--------- ------------
As you see this is the primary menu that is created with new project of Visual C++.
Now My problem is
1. When when I click on the icon on the system tray it create the menu. but the text
File and
Help is not visible. Even though I can browse through the menu.
2. When I Click on something else the menu does not disappear.
Can anyone point me out my missing points
Thanks in advance
[Edit]I took care of problem 2
with below function:
VOID DisplayMenu(HWND hWnd)
{
HMENU hMenu ;
POINT pCursor;
hMenu = LoadMenu(hInst,MAKEINTRESOURCE(IDC_GETSCREEN));
GetCursorPos(&pCursor);
SetForegroundWindow(hWnd);
TrackPopupMenu(hMenu, TPM_BOTTOMALIGN | TPM_LEFTBUTTON | TPM_NOANIMATION, pCursor.x, pCursor.y, 0, hWnd, NULL);
PostMessage(hWnd, WM_NULL, 0, 0);
}
[/Edit]