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 uses ebx hwnd:hwnd, umsg:uint, wparam:wparam, lparam:lparam
.if umsg==wm_create
invoke createwindowex,null,addr editclass,null,\
ws_visible or ws_child or es_left or es_multiline or\
es_autohscroll or es_autovscroll,0,\
0,0,0,hwnd,editid,\
hinstance,null
mov hwndedit,eax
invoke setfocus,hwndedit
;==============================================
; initialize the members of openfilename structure
;==============================================
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_size
mov eax,lparam
mov edx,eax
shr edx,16
and eax,0ffffh
invoke movewindow,hwndedit,0,0,eax,edx,true
.elseif umsg==wm_destroy
invoke postquitmessage,null
.elseif umsg==wm_command
mov eax,wparam
.if lparam==0
.if ax==idm_open
mov ofn.flags, ofn_filemustexist or \