Visual C++ -->Accelerator Problem

Started by
1 comment, last by gamedream 20 years, 8 months ago
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
Advertisement
I have found the solutin la, thx your help
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?

This topic is closed to new replies.

Advertisement