RadASM DialogApp, DialogAsMain and tabbing between controls???

Started by hotrod, December 02, 2009, 08:05:05 PM

Previous topic - Next topic

hotrod

DailogAsMain disables tabbing between controls while DialogApp allows it when created using RadASM, does anyone know why? If so, what can be done to get DialogAsMain to allow tabbing?

Spare us the title changes, this is a members forum, not a help desk.

MichaelW

I have no experience with RadASM, but assuming that these are modeless dialogs I would guess that the choice that allows tabbing between controls is using IsDialogMessage in the message loop, instead of the conventional TranslateMessage-DispatchMessage.
eschew obfuscation

farrier

hotrod,

MichaelW is correct.  An example of how a "regular" window and a dialog differ.  See:

http://www.masm32.com/board/index.php?topic=2942.0

hth,

farrier
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

hotrod

I guess I should have attached examples to start with, but here they are now. The .zip contains 2 projects.

MichaelW

Tab Controls.Asm creates a modal dialog for which the system provides a message loop.

No Tab Controls.Asm creates a modeless dialog, where the message loop uses TranslateMessage and DispatchMessage. You can correct the problem by substituting IsDialogMessage. Or for maximum flexibility, since there are a few messages that IsDialogMessage cannot process, you can also include TranslateMessage and DispatchMessage in the message loop, but you must avoid passing a message that IsDialogMessage has processed to TranslateMessage and DispatchMessage, as described in the documentation. I cannot test any of this, but something like this should work:

invoke CreateDialogParam,hInstance,IDD_DIALOG,NULL,addr WndProc,NULL
mov hWnd,eax  ; <------<<<<
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.BREAK .if !eax
invoke IsDialogMessage,hWnd,addr msg
.if eax == 0
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endif
.endw


Note that I added code to store the HWND returned by CreateDialogParam to the variable hWnd, since I can't see how the application could work without this.
eschew obfuscation

hotrod

MichaelsW, you hit the nail on the head. It took both saving hWnd and IsDialogMessage to make it work. I was "assuming" that the template file was correct, but apparently it needs some work. It will also take a SetFocus to get the first control selected. Thanks for you help.

MichaelW

QuoteIt will also take a SetFocus to get the first control selected.

I think you can control that by returning TRUE from your WM_INITDIALOG handler.

eschew obfuscation

hotrod

You are right again; thanks for spreading around the knowledge.