first of all, dont tell me to use a resource editor, i like run time stuff okay?
second, here's the problem: i cant get accelerators to work when i add them at run time.
what i do is allocate memory for however many ACCEL structures i require. ie,
Code:
LocalAlloc(LPTR,num_accels*sizeof(ACCEL));
then i use LocalLock to obtain a pointer, put some data in:
Code:
AccelPointer[0].cmd=ID_ACCEL_QUIT;
AccelPointer[0].fVirt=FALT|FCONTROL;
AccelPointer[0].key=122;
and then create the table.
Code:
accTable=CreateAcceleratorTable(AccelPointer,
num_accels);
All throughout, i have been checking each function for error return values, but everything seems to be running perfectly.
then i add this to the message loop:
Code:
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
if(!TranslateAccelerator(Msg.hwnd, accTable, &Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
and put some capturing code in WM_COMMAND. by the way, there are no child windows in this program, so i dont need to subclass or anything to get the accelerator message.
something is not right, because spy++ shows that no message is being sent for the accelerator, just the usual bunch of keydown and keyup messages. how do i fix it?