Archived

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

gamedream

Visual C++ -->Accelerator Problem

Recommended Posts

gamedream    122
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
gamedream    122
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