invoke getmodulehandle, null
mov hinstance,eax
invoke getcommandline
mov commandline,eax
invoke winmain, hinstance,null,commandline, sw_showdefault
invoke exitprocess,eax
winmain proc hinst:hinstance,hprevinst:hinstance,cmdline:lpstr,cmdshow:dword
local wc:wndclassex
local msg:msg
local hwnd:hwnd
mov wc.cbsize,sizeof wndclassex
mov wc.style, cs_hredraw or cs_vredraw
mov wc.lpfnwndproc, offset wndproc
mov wc.cbclsextra,null
mov wc.cbwndextra,null
push hinst
pop wc.hinstance
mov wc.hbrbackground,color_window+1
mov wc.lpszmenuname,offset menuname
mov wc.lpszclassname,offset classname
invoke loadicon,null,idi_application
mov wc.hicon,eax
mov wc.hiconsm,eax
invoke loadcursor,null,idc_arrow
mov wc.hcursor,eax
invoke registerclassex, addr wc
invoke createwindowex,ws_ex_clientedge,addr classname,\
addr appname, ws_overlappedwindow,cw_usedefault,\
cw_usedefault,300,200,null,null,\
hinst,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 translatemessage, addr msg
invoke dispatchmessage, addr msg
.endw
mov eax,msg.wparam
ret
winmain endp
wndproc proc hwnd:hwnd, umsg:uint, wparam:wparam, lparam:lparam
.if umsg==wm_create
invoke getmenu,hwnd ;obtain the menu handle
mov hmenu,eax
mov ofn.lstructsize,sizeof ofn
push hwnd
pop ofn.hwndowner
push hinstance
pop ofn.hinstance
mov ofn.lpstrfilter, offset filterstring
mov ofn.lpstrfile, offset buffer
mov ofn.nmaxfile,maxsize
.elseif umsg==wm_destroy
.if hmapfile!=0
call closemapfile
.endif
invoke postquitmessage,null
.elseif umsg==wm_command
mov eax,wparam
.if lparam==0
.if ax==idm_open
mov ofn.flags, ofn_filemustexist or \