Hi there I'm trying to get accelerators working in my program, and can't seem to get it to work. Can anyone give me some suggestions? I think the problem may lie in my loop. Here's an excerpt from my program: invoke LoadAccelerators, hInst, IDA_ACCEL ;Load accelerators ; from resource test eax,eax ;Did we error out? jz ExitLoop ;If so let's quit mov hAccel,eax ;Otherwise remember our Accelerator handle ;=================================== ; Loop until PostQuitMessage is sent ;=================================== StartLoop: ;Get the next windows message invoke GetMessage,ADDR msg,NULL,0,0 cmp eax, 0 ;Is this message a message to quit? je ExitLoop ;If so exit, otherwise continue ;Check if we have an accelerator pressed invoke TranslateAccelerator, msg.hwnd, hAccel, ADDR msg test eax,eax jnz StartLoop invoke TranslateMessage, ADDR msg invoke DispatchMessage, ADDR msg jmp StartLoop ExitLoop: return msg.wParam Anybody know what's wrong? Thanks, Ben
Posted on 2000-12-17 17:29:00 by cyberben
The handle in TranslateAccelerator is supposed to be for the window that handles the WM_COMMAND or WM_SYSCOMMAND message. The window msg.hwnd may be a control handle because of focus (which determines where keyboard messages normally go).
Posted on 2000-12-18 16:26:00 by ub1
This is one way. N O T E ! The hFRDlg and hSUDlg are for dialogs. INVOKE LoadAccelerators, hInst, IDR_ACCEL test eax, eax jz EndLoop mov hAccel, eax BeginLoop: INVOKE GetMessage, offset msg, 0, 0, 0 cmp ax, 0 je EndLoop INVOKE TranslateAccelerator, hWnd, hAccel, offset msg cmp eax, 0 jne BeginLoop INVOKE IsDialogMessage, hFRDlg, offset msg cmp eax, 0 jne BeginLoop INVOKE IsDialogMessage, hSUDlg, offset msg cmp eax, 0 jne BeginLoop INVOKE TranslateMessage, offset msg INVOKE DispatchMessage, offset msg jmp BeginLoop EndLoop: Ewayne
Posted on 2000-12-18 17:50:00 by Ewayne