This program make a model dialog,but i can not understand somewhere
.386
.model flat, stdcall
option casemap :none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Include ???????
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Equ
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ICO_MAIN equ 1000h ;icon
DLG_MAIN equ 1
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; data
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?

hInstance dd ?
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcDlgMain proc uses ebx edi esi hWnd,wMsg,wParam,lParam

mov eax,wMsg
.if eax == WM_CLOSE
invoke EndDialog,hWnd,NULL
.elseif eax == WM_INITDIALOG
invoke LoadIcon,hInstance,ICO_MAIN
invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
.elseif eax == WM_COMMAND
mov eax,wParam
.if ax == IDOK
invoke EndDialog,hWnd,NULL
.endif
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_ProcDlgMain endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,DLG_MAIN,NULL,offset _ProcDlgMain,NULL
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end start
1.The first question is why use mov eax,FALSE
2.The second question is why use ret tow times?
3.The third question is why use mov eax,TRUE
Posted on 2003-08-27 05:55:28 by tomorrow
1.The first question is why use mov eax,FALSE
To indicate to Windows that you HAVE processed the message.

2.The second question is why use ret tow times?
Because you have two exit points from the function. You can have a million exit points if you wish.

3.The third question is why use mov eax,TRUE
To indicate to Windows that you have NOT dealt with the message.


Note that you have your mov eax, TRUE and mov eax, FALSE around the wrong way. You really should read this tutorial.
Posted on 2003-08-27 06:10:11 by sluggy
Thank you for answer my question.
question 1 and 3 i understand.but 2 answer you say
Because you have two exit points from the function. You can have a million exit points if you wish.
i can not understand. can you tell me what dose exit points mean and where i hava two exit points.
Posted on 2003-08-27 06:18:36 by tomorrow
It is a function, a self contained piece of code, it is designed to a specific job. It can be called from anywhere, and you always enter at the same spot, but you can leave it at any time and return to the piece of code that called it.
Posted on 2003-08-27 06:26:48 by sluggy
i can not understand you,you mean use ret because i use invok function.but i use it so many.
Posted on 2003-08-27 06:52:22 by tomorrow
anybody here
Posted on 2003-08-27 07:12:47 by tomorrow
ret is masm's marco for the opcode retn xx. The reason why there is 2 ret is that the coder want to exit from the function with different values in eax. That's the only reason why there is 2 ret.
Posted on 2003-08-27 07:36:56 by roticv
roticy ,thankyou.nice to meet you
Posted on 2003-08-27 07:51:05 by tomorrow
You call a function, so you must return from it. 'ret' is a macro for the 'return' opcode. You can return from a function at any point within that function.

This is all absolute basic coding practice, regardless of the language being used.
Posted on 2003-08-27 08:13:24 by sluggy

--------------------------------------------------------------------------------
1.The first question is why use mov eax,FALSE
--------------------------------------------------------------------------------

To indicate to Windows that you HAVE processed the message.

--------------------------------------------------------------------------------
3.The third question is why use mov eax,TRUE
--------------------------------------------------------------------------------

To indicate to Windows that you have NOT dealt with the message.


May be im wrong but I think the opposite is true, you should return TRUE if you have processed the message. WM_INITDIALOG is an exception, returning TRUE here means windows should set focus.

Japheth
Posted on 2003-08-27 08:40:58 by japheth