News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Dialog As Main

Started by BugCatcher, October 11, 2024, 08:39:32 AM

Previous topic - Next topic

BugCatcher

Here is a Dialog as Main simple skeleton

NoCforMe

I really like using dialogs as main program windows: let the dialog manager do the heavy lifting, no window creation necessary. (I have a homemade dialog template creator, so I don't even have to link in a resource file: the dialog is created as an in-memory template. Very simple.)

I don't do 64 bits so probably won't use your example, but it's a very good technique to have in your toolbox.
Assembly language programming should be fun. That's why I do it.

ognil

#2

Thank you BugCatcher, :thumbsup:
"Not keeping emotions under control is another type of mental distortion."

NoCforMe

Hmm; when I run this I get a blank window, black, with the title "IDD_DLG". No menu, no nothing.
Assembly language programming should be fun. That's why I do it.

zedd151

#4
Quote from: NoCforMe on October 11, 2024, 11:21:31 AMHmm; when I run this I get a blank window, black, with the title "IDD_DLG". No menu, no nothing.
Apparently it is a "bare bones" template or "skeleton" for the user to use as they see fit. He did say it was a "skeleton".   :smiley:

Thanks for sharing the example, BugCatcher.   :thumbsup:
Ventanas diez es el mejor.  :azn:

Vortex

Here is another dialog box with menu.

NoCforMe

Good. I was going to suggest that you at least minimally populate the dialog with something, which I see you've done, so that n00bs will get the idea.

Dialogs are kewl.
Assembly language programming should be fun. That's why I do it.

ognil

#7
Thank you Vortex, :thumbsup:

Same but not as complicated and 1K shorter:

include     Dialog64.inc

.code

start           proc 
                xor     ecx, ecx
                call    GetModuleHandle             ; invoke  GetModuleHandle,NULL
                lea     rcx, DialogBoxParam
                xor     r8d, r8d
                xchg    rcx, rax
                lea     r9,  DlgProc      
                mov     [rsp+4*8],r8
                lea     rdx, Resource
                call    qword ptr [rax]             ; invoke  DialogBoxParam,rcx,ADDR Resource,NULL,ADDR DlgProc,NULL
start           endp

DlgProc         proc
                cmp     rdx,WM_CTLCOLORDLG
                jne     Is_WM_CLOSE
                mov     ecx, 0FF0000h
                call    CreateSolidBrush            ; invoke  CreateSolidBrush,Blue=0FF0000hh
                mov     hBrush,rax
                ret
Is_WM_CLOSE:
                cmp     rdx,WM_CLOSE
                je      @Ret
Is_WM_COMMAND:
                cmp     rdx, WM_COMMAND
                jne     @Exit
                test    r9, r9
                jne     @Is_BN_CLICKED
               
                cmp     r8w, IDM_EXIT
                je      @Ret
                cmp     r8w, IDM_ABOUT
                jne     @Exit
                mov     r9d, MB_OK
                lea     r8,  title1
                lea     rdx, msg
                xor     ecx, ecx
                call    MessageBox                  ; invoke  MessageBox,NULL,ADDR msg,ADDR title1,MB_OK
                jmp     @Exit
@Is_BN_CLICKED:
                mov     rax, r8
                shr     rax, 16
                cmp     ax, BN_CLICKED
                jne     @Exit
                cmp     r8w, IDC_EXIT
                je      @Ret
                cmp     r8w, IDC_ABOUT
                jne     @Exit
                xor     r9d,r9d
                mov     r8d, IDM_ABOUT
                mov     edx, WM_COMMAND
                call    SendMessage                 ; invoke  SendMessage,hWnd,WM_COMMAND,IDM_ABOUT,0
                jmp     @Exit
@Ret:   
                xor     ecx, ecx
                call    ExitProcess                 ; invoke  ExitProcess,rcx
@Exit:       
                xor     eax, eax
                ret
DlgProc         endp

END

"Not keeping emotions under control is another type of mental distortion."

ognil

Hi,

With shorter ON_WM_COMMAND without BN_CLICKED: :badgrin:
Is_WM_COMMAND:
                cmp     rdx, WM_COMMAND
                jne     @Exit
                cmp     r8w, IDM_EXIT
                je      @Ret
                cmp     r8w, IDC_EXIT
                je      @Ret
                cmp     r8w, IDM_ABOUT
                je      @Mess
                cmp     r8w, IDC_ABOUT
                jne     @Exit
@Mess:
                mov     r9d, MB_OK
                lea     r8,  title1
                lea     rdx, msg
                xor     ecx, ecx
                call    MessageBox                  ; invoke  MessageBox,NULL,ADDR msg,ADDR title1,MB_OK
@Exit:
                xor     eax, eax
ret
@Ret:
                xor     ecx, ecx
                call    ExitProcess                 ; invoke  ExitProcess,rcx
DlgProc         endp
:smiley:
"Not keeping emotions under control is another type of mental distortion."