| | |
How to activate pop-up menus without changing foreground window?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2008
Posts: 13
Reputation:
Solved Threads: 0
I am trying to mimic the behavior of Language Indicator pop-up menus (which pop-up when you do left or right mouse click on the Language Indicator), so the foreground window and focus do not change, and it is still possible to use keyboard to select or cancel menu (arrow keys or Escape).
I need this for tray menu, as well as for a general pop-up menu which can be activated at any time by pressing certain keys. And of course, I am hooking to WH_KEYBOARD_LL and WH_MOUSE_LL events properly.
My application is supposed to be running under XP or Vista (2000 is nice to have, but not essential). I am developing it under Vista in Visual Studio 2008 Standard Edition.
The best solution so far was to have something like described on social.msdn:
Foreground window does not change, mouse navigation is working fine, selection by click is fine, BUT keyboard is not working (you can neither use arrow keys to navigate through menu items, nor press Escape to cancel menu). And also, mouse cursor does not always switch from I-beam to default arrow image when activating menu with Notepad application at foreground.
Is there a proper way to create truly pop-up menus avoiding notorious TrackPopupMenu's requirement to switch foreground window to my app? Should be the only solution to create my own window and simulate menu activities? And still, wouldn't I need to switch foreground window for the period when such 'pop-up menu' is active?
I need this for tray menu, as well as for a general pop-up menu which can be activated at any time by pressing certain keys. And of course, I am hooking to WH_KEYBOARD_LL and WH_MOUSE_LL events properly.
My application is supposed to be running under XP or Vista (2000 is nice to have, but not essential). I am developing it under Vista in Visual Studio 2008 Standard Edition.
The best solution so far was to have something like described on social.msdn:
C++ Syntax (Toggle Plain Text)
HWND hwndActive = GetForegroundWindow(); DWORD thisThreadId = GetCurrentThreadId(); DWORD activeThreadId = GetWindowThreadProcessId(hwndActive, NULL); AttachThreadInput(thisThreadId, activeThreadId, TRUE); UINT result = (UINT)TrackPopupMenu(...); AttachThreadInput(thisThreadId, activeThreadId, FALSE); BringWindowToTop(hwndActive);
Is there a proper way to create truly pop-up menus avoiding notorious TrackPopupMenu's requirement to switch foreground window to my app? Should be the only solution to create my own window and simulate menu activities? And still, wouldn't I need to switch foreground window for the period when such 'pop-up menu' is active?
Last edited by Ancient Dragon; Feb 18th, 2009 at 8:49 am. Reason: add code tags
![]() |
Other Threads in the C++ Forum
- Previous Thread: VS2008 error
- Next Thread: Using the console without the iostream
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets





