943,935 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3215
  • C++ RSS
Jul 30th, 2007
0

Getting Menu Item info for pop-up menus from System Tray Icons

Expand Post »
I am trying to figure out a way of retrieving/enumerating menu items that pops up from one of my application system tray icons when I right click on it, and seeing which menu item is checked.

So far what I've done...
I've used Winspector to find that the tray icon itself for the application does not have its own window class, so I retrieved its handle through the "ToolbarWindow32" class, by getting a handle on the tray process, getting a count of the "Button"s inside the tray, and iterating through each one to find the application that I am trying to access.

C++ Syntax (Toggle Plain Text)
  1. for(int iButton=0; iButton<iButtonsCount; iButton++)
  2. {
  3. DWORD dwBytesRead = -1;
  4. TBBUTTON buttonData;
  5. SendMessage(hWndTray, TB_GETBUTTON, iButton, (LPARAM)lpData);
  6.  
  7. ReadProcessMemory(hTrayProc, lpData, &buttonData,
  8. sizeof(TBBUTTON), &dwBytesRead);
  9. DWORD dwExtraData[2] = { 0,0 };
  10. ReadProcessMemory(hTrayProc, (LPVOID)buttonData.dwData,
  11. dwExtraData, sizeof(dwExtraData), &dwBytesRead);
  12.  
  13. HWND hWndOfIconOwner = (HWND) dwExtraData[0];
  14. int iIconId = (int) dwExtraData[1];
  15.  
  16. if( !(buttonData.fsState & TBSTATE_HIDDEN) )
  17. {
  18. HMENU hMenu = GetMenu(hWndOfIconOwner);
  19. }
  20. }

If you take a look at the last if statement, I check whether the current icon is showing, and if it is it gets the handle to the menu. I'm not too sure whether doing GetMenu is actually getting the handle of the same menu as when I right click on it.

Basically, if I right click on the icon, it pops up a menu, and there is a menu item with a submenu with a list of items which can be checked. All I want to do see which ones is checked.

Thanks for any response in advance.

noit
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
noituloverx is offline Offline
1 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: GUI proram organization question
Next Thread in C++ Forum Timeline: Maya API





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC