i created an accelerator with an ID of ACCEL_QUIT. In the window procedure, in WM_COMMAND, i try to capture ACCEL_QUIT using LOWORD(wParam). ACCEL_QUIT is defined at the top of the source file. nothing happens though, i cannot seem to capture the message anywhere. how do i do this?
Usually you have to have a modified Message Loop.
Make sure that TranslateAccelerator gets called before GetMessage.... then you will intercept the Accelerator.
i still cant get it to work. here is my setup:
i then do the following:
while(GetMessage(&Msg, NULL, 0, 0) > 0)
nothing happens. since the whole window is covered by an edit box, which always has focus, i modified it, gave focus to the window, but still nothing. is the order of my operations wrong?
case ACCEL_QUIT: //this is the ID
//do stuff here
if still having problems post the actual record from the acc table as well.
while(GetMessage(&msg, NULL , 0, 0))
if(!TranslateAccelerator( msg.hwnd, hAccel, &msg))
no that still wont work
i dont see why would want the accelerator table, but here go
by the way, that was created by the resource editor in MSVC++ 98.
IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE
"Z", ACCEL_QUIT, VIRTKEY, CONTROL, ALT, NOINVERT
perhaps i am not loading the accelerator table properly?
that code is just before the message loop.
this is really annoying, and i cant find anything on the internet about how to do it, except with class based code, which i dont like to use. anyone have any ideas for me?
So you are pressing 'z' + 'ctrl' + 'alt' ?
What int have you defined ACCEL_QUIT as?
#define ACCEL_QUIT 40001
What happens in the callback under the case ACCEL_QUIT: any msg's incomming?
GetLastError() if table = NULL
yeah, there was an error loading the table. i specified the parameter for the accelerator table incorrectly. what i was supposed to do was specify 0 as the high order word, and a MAKEINTRESOURCE(tableID) as the low order word. the problem now is, how do i specify that? i know how to refer to the low and high words, like this:
But i dont know how to assign to these words. could someone help?
actually, i found out how to make the word. i found the MAKELONG() function. i assume this is the right function, because it returns a 4 byte value, and the parameter requires a 4 byte pointer to a char. here is the help text:
Points to a null-terminated string that names the accelerator table to load. Alternatively, this parameter can specify the resource identifier of an accelerator-table resource in the low-order word and zero in the high-order word. The MAKEINTRESOURCE macro can be used to create this value.
And this is the code:
i type casted the second parameter to a pointer because the compiler told me to. is this all correct?