flat assembler
Message board for the users of flat assembler.

Index > Windows > Sometimes the dialog won't show

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Code:
include '%fasminc%\Win32ax.inc'
include '%fasminc%\macro\if.inc'

IDD_DLG1 equ 1
BTNEXIT equ 1000
IDC_GRP1 equ 1001
EDITTEXT equ 1002

main:
        invoke GetModuleHandle,0
        invoke DialogBoxParam,eax,1,0,DlgProc,0 
        invoke ExitProcess,0

proc DlgProc,hWnd,uMsg,wParam,lParam

.if [uMsg]=WM_CLOSE
        invoke EndDialog,[hWnd],1
.elseif [uMsg]=WM_COMMAND
        mov eax,[wParam]
        .if ax=BTNEXIT
                push [hWnd]
                call ExitProg
        .endif
.endif
xor eax,eax
ret

endp

proc ExitProg,hwnd
        invoke MessageBox,[hwnd],"Exit?","Dialog Test",MB_YESNO
        ;.if eax = IDNO  ;IF I UNCOMMENT CONDITIONS LIKE THIS THE DIALOG WON'T SHOW ANYMORE
        ;       ret                      ;WHAT'S WRONG? IT SEEMS THAT WHEN I ADD MORE CODE THE DIALOG WON'T SHOW
        ;.endif
        invoke EndDialog,[hwnd],1
        ret
endp


data resource from 'test.res'
end data

.end main    


Last edited by OzzY on 01 Mar 2006, 17:02; edited 1 time in total
Post 01 Mar 2006, 16:58
View user's profile Send private message Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
I changed to this and worked:
Code:
include '%fasminc%\Win32ax.inc'
include '%fasminc%\macro\if.inc'

IDD_DLG1 equ 1
BTNEXIT equ 1000
IDC_GRP1 equ 1001
EDITTEXT equ 1002

main:
        invoke GetModuleHandle,0
        invoke DialogBoxParam,eax,1,0,DlgProc,0 
        invoke ExitProcess,0

proc DlgProc,hWnd,uMsg,wParam,lParam

.if [uMsg]=WM_CLOSE
        invoke EndDialog,[hWnd],1
.elseif [uMsg]=WM_COMMAND
        mov eax,[wParam]
        .if ax=BTNEXIT
                push [hWnd]
                call ExitProg
        .endif
.endif
xor eax,eax
ret

endp

data resource from 'test.res'
end data

proc ExitProg,hwnd
        invoke MessageBox,[hwnd],"Exit?","Dialog Test",MB_YESNO
        .if eax = IDNO  ;IF I UNCOMMENT CONDITIONS LIKE THIS THE DIALOG WON'T SHOW ANYMORE
              ret                      ;WHAT'S WRONG? IT SEEMS THAT WHEN I ADD MORE CODE THE DIALOG WON'T SHOW
        .endif
        invoke EndDialog,[hwnd],1
        ret
endp

.end main
    

Why?
Post 01 Mar 2006, 17:01
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
If you end data - the assembler doesn't implicitly state that the next is .code section, but if you move your data section to the very end - the code section is contiguous.
Post 02 Mar 2006, 08:18
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav
it's recommended to preserve main registers in DlgProc (ebx,esi,edi)
Post 02 Mar 2006, 15:59
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
it's required, not recommended. But he doesn't seem to change them anywhere
Post 02 Mar 2006, 16:02
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.