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

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2007
Posts: 1
Reputation: noituloverx is an unknown quantity at this point 
Solved Threads: 0
noituloverx noituloverx is offline Offline
Newbie Poster

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

 
0
  #1
Jul 30th, 2007
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.

  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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC