• Advertisement

Archived

This topic is now archived and is closed to further replies.

Visual C++ -->Accelerator Problem

This topic is 5277 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I want to use Accelerator Keystroke, I will use this : while(1) { if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) break; if (!TranslateAccelerator(hWnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } } The above code cannot get the WM_COMMAND, on the other words, it cannot do the action when keystroke but when I use Visual C++ to generate the "HelloWorld" Example, it can work when it use this : while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } So, my question is why the first code cannot work, but the second is work thx for help

Share this post


Link to post
Share on other sites
Advertisement
The solution is hWnd and msg.hwnd.
When I use hWnd to replace it in the TranslateAccelerator(), it doesn''t work, but if I place msg.hwnd, it can work, but I don''t know what are they different? msg.hwnd is not refer to hWnd???
anyone can tell me why?

Share this post


Link to post
Share on other sites

  • Advertisement