There are 2 edit boxes, along with some other controls, on a dialog that is subclassed.

The following will intercept WM_CHAR or WM_KEYDOWN, but cannot tab between editboxes.
	.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.BREAK .if !eax
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
        .endw


The following will intercept WM_CHAR or tabbing between editboxes, but will not read WM_KEYDOWN:
 .while TRUE
invoke GetMessage,addr msg,NULL,0,0
.BREAK .if !eax
invoke IsDialogMessage, hWnd, ADDR msg
.if !eax
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endif
.endw


The following will intercept WM_CHAR, WM_KEYDOWN and tabbing between editboxes. The problem is that it will insert 4 characters for everyone typed:
	.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.BREAK .if !eax
invoke IsDialogMessage, hWnd, ADDR msg
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw


How can WM_CHAR, WM_KEYDOWN and tabbing between editboxes be handled correctly?

Thanks,
Posted on 2009-03-04 16:48:06 by green
The second loop is correct. You should be calling IsDialogMessage, and if that returns 0, calling TranslateMessage/DispatchMessage.

The problem with the second loop, like you stated, is that it won't detect WM_KEYDOWN. This is because the dialog manager (the stuff inside IsDialogMessage) will be swallowing the message. You should modify your loop slightly as described here:

http://blogs.msdn.com/oldnewthing/archive/2005/04/07/406012.aspx
Posted on 2009-03-08 06:32:15 by comrade
Thanks comrad, but even though this worked, it created another problem with the program shuting down. See the following:
	.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.if msg.message==WM_KEYDOWN
invoke GetFocus
.if eax==hCBO_CATAGORY   ; Combobox
invoke BtnCatProc ; Button
.endif
.endif
  .BREAK .if !eax
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw

This simply changes the caption on a button:
BtnCatProc PROC
invoke SendMessage,hCBO_CATAGORY,CB_GETCURSEL,0,0
.if eax==15 ; position in combo
invoke SetWindowText,hBTN_CATAGORY,SADD("Go to demonstration")
.endif
ret
BtnCatProc endp

Then comes the shutdown.
Posted on 2009-03-08 11:26:34 by green
Your loop is still a bit incorrect. At the line where you do ".break .if !eax", you should be evaluating the eax from GetMessage. But if WM_KEYDOWN is sent, you will overwrite the contents of eax when calling GetFocus/BtnCatProc. As well, you should not attempt to do any of this for WM_KEYDOWN.

Try something like this (this is a literal translation from the oldnewthing blogpost):
.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.break if !eax || eax==0xFFFFFFFF
.if msg.message==WM_KEYDOWN
invoke GetFocus
.if eax==hCBO_CATAGORY  ; Combobox
invoke BtnCatProc ; Button
.endif
.else
invoke IsDialogMessage, hWnd, ADDR msg
.if !eax
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endif
.endif
.endw
Posted on 2009-03-09 02:04:58 by comrade
Thanks comrad, I appreciate the help. Lot to learn.
Posted on 2009-03-09 07:24:31 by green
Sorry about calling you comrad, comrade. Get my finger tangled up in the keyboard.

Made a slight change to your code to get the tab key to work:

		.while TRUE
invoke GetMessage,addr msg,NULL,0,0 ; New location
.break .if !eax || eax==0FFFFFFFFh
invoke IsDialogMessage, hWnd, ADDR msg
.if msg.message==WM_KEYDOWN
invoke GetFocus
.if msg.wParam==VK_RETURN && eax==hCBO_CATAGORY
invoke testproc1 ; Button
.endif
.else
                                     ;invoke GetMessage,addr msg,NULL,0,0 ; Old location
.if !eax
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endif
.endif
.endw

Posted on 2009-03-10 06:10:31 by green