; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
.486 ; create 32 bit code
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
; include files
; ~~~~~~~~~~~~~
include \masm32\include\windows.inc
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\Comctl32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\shell32.inc
include \masm32\include\oleaut32.inc
include \masm32\macros\macros.asm ; the macro file
; libraries
; ~~~~~~~~~
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\Comctl32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\oleaut32.lib
include \masm32\include\dialogs.inc
DlgProc1 PROTO :DWORD,:DWORD,:DWORD,:DWORD
.data?
hInstance dd ?
.code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
mov hInstance, FUNC(GetModuleHandle,NULL)
call main
invoke ExitProcess,eax
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
main proc
; ------------------------------------------------------------------
; the following equates are used to maintain the position of the
; button when the window or button sizes are changed. The advantage
; of this technique is that the calculations are done at assembly
; time so there is no runtime overhead doing the calculations.
; ------------------------------------------------------------------
wWid equ 220 ; window width
wHgt equ 120 ; window heigt
bWid equ 40 ; button width
bHgt equ 12 ; button height
wStp equ bHgt + 2 ; step between buttons
wStt equ 5 ; start from top of window
Dialog "MASM32 Dialog", \ ; caption
"MS Sans Serif",8, \ ; font,pointsize
WS_OVERLAPPED or \ ; styles for
WS_SYSMENU or DS_CENTER, \ ; dialog window
3, \ ; number of controls
50,50,wWid,wHgt, \ ; x y co-ordinates
1024 ; memory buffer size
DlgButton "OK",WS_TABSTOP, wWid - (bWid + 10),wStt, bWid,bHgt,IDOK
DlgButton "Cancel",WS_TABSTOP, wWid - (bWid + 10),wStt+wStp, bWid,bHgt,IDCANCEL
DlgButton "Help",WS_TABSTOP, wWid - (bWid + 10),wStt+wStp*2,bWid,bHgt,100
CallModalDialog hInstance,0,DlgProc1,NULL
ret
main endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
DlgProc1 proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
.if uMsg == WM_INITDIALOG
invoke SendMessage,hWin,WM_SETICON,1,
FUNC(LoadIcon,NULL,IDI_APPLICATION)
.elseif uMsg == WM_COMMAND
.if wParam == IDOK
invoke MessageBox,hWin,SADD("You pressed the OK button"),SADD("OK"),MB_OK
.elseif wParam == 100
invoke MessageBox,hWin,SADD("You pressed the Help button"),SADD("Help"),MB_OK
.elseif wParam == IDCANCEL
jmp quit_dialog
.endif
.elseif uMsg == WM_CLOSE
quit_dialog:
invoke EndDialog,hWin,0
.endif
xor eax, eax
ret
DlgProc1 endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start