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,
then i use LocalLock to obtain a pointer, put some data in:Code:LocalAlloc(LPTR,num_accels*sizeof(ACCEL));
and then create the table.Code:AccelPointer[0].cmd=ID_ACCEL_QUIT; AccelPointer[0].fVirt=FALT|FCONTROL; AccelPointer[0].key=122;
All throughout, i have been checking each function for error return values, but everything seems to be running perfectly.Code:accTable=CreateAcceleratorTable(AccelPointer, num_accels);
then i add this to the message loop:
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.Code:while(GetMessage(&Msg, NULL, 0, 0) > 0) { if(!TranslateAccelerator(Msg.hwnd, accTable, &Msg)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } }
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?



LinkBack URL
About LinkBacks
.


