overlappedwindow,cw_usedefault, cw_usedefault,cw_usedefault,cw_usedefault,null,null, hinst,null mov hwnd,eax invoke showwindow, hwnd,sw_shownormal invoke updatewindow, hwnd invoke loadaccelerators,hinstance,idr_mainaccel mov haccel,eax .while true invoke getmessage, addr msg,0,0,0 .break .if (!eax) invoke isdialogmessage,hsearch,addr msg .if eax==false invoke translateaccelerator,hwnd,haccel,addr msg .if eax==0 invoke translatemessage, addr msg invoke dispatchmessage, addr msg .endif .endif .endw mov eax,msg.wparam ret winmain endp streaminproc proc hfile:dword,pbuffer:dword, numbytes:dword, pbytesread:dword invoke readfile,hfile,pbuffer,numbytes,pbytesread,0 xor eax,1 ret streaminproc endp streamoutproc proc hfile:dword,pbuffer:dword, numbytes:dword, pbyteswritten:dword invoke writefile,hfile,pbuffer,numbytes,pbyteswritten,0 xor eax,1 ret streamoutproc endp checkmodifystate proc hwnd:dword invoke sendmessage,hwndrichedit,em_getmodify,0,0 .if eax!=0 invoke messagebox,hwnd,addr wannasave,addr appname,mb_yesnocancel .if eax==idyes invoke sendmessage,hwnd,wm_command,idm_save,0 .elseif eax==idcancel mov eax,false ret .endif .endif mov eax,true ret checkmodifystate endp setcolor proc local cfm:charformat invoke sendmessage,hwndrichedit,em_setbkgndcolor,0,backgroundcolor invoke rtlzeromemory,addr cfm,sizeof cfm mov cfm.cbsize,sizeof cfm mov cfm.dwmask,cfm_color push textcolor pop cfm.crtextcolor invoke sendmessage,hwndrichedit,em_setcharformat,scf_all,addr cfm ret setcolor endp optionproc proc hwnd:dword, umsg:dword, wparam:dword, lparam:dword local clr:choosecolor .if umsg==wm_initdialog .elseif umsg==wm_command mov eax,wparam shr eax,16 .if ax==bn_clicked mov eax,wparam .if ax==idcancel invoke sendmessage,hwnd,wm_close,0,0 .elseif ax==idc_backcolorbox invoke rtlzeromemory,addr clr,sizeof clr mov clr.lstructsize,sizeof clr push hwnd pop clr.hwndowner push hinstance pop clr.hinstance push backgroundcolor pop clr.rgbresult mov clr.lpcustcolors,offset customcolors mov clr.flags,cc_anycolor or cc_rgbinit invoke choosecolor,addr clr .if eax!=0 push clr.rgbresult pop backgroundcolor invoke getdlgitem,hwnd,idc_backcolorbox invoke invalidaterect,eax,0,true .endif .elseif ax==idc_textcolorbox invoke rtlzeromemory,addr clr,sizeof clr mov clr.lstructsize,sizeof clr push hwnd pop clr.hwndowner push hinstance pop clr.hinstance push textcolor pop clr.rgbresult mov clr.lpcustcolors,offset customcolors mov clr.flags,cc_anycolor or cc_rgbinit invoke choosecolor,addr clr .if eax!=0 push clr.rgbresult pop textcolor invoke getdlgitem,hwnd,idc_textcolorbox invoke invalidaterect,eax,0,true .endif .elseif ax==idok invoke sendmessage,hwndrichedit,em_getmodify,0,0 push eax invoke setcolor pop eax invoke sendmessage,hwndrichedit,em_setmodify,eax,0 invoke enddialog,hwnd,0 .endif .endif .elseif umsg==wm_ctlcolorstatic invoke getdlgitem,hwnd,idc_backcolorbox .if eax==lparam invoke createsolidbrush,backgroundcolor ret .else invoke getdlgitem,hwnd,idc_textcolorbox .if eax==lparam invoke createsolidbrush,textcolor ret .endif .endif mov eax,false ret .elseif umsg==wm_close invoke enddialog,hwnd,0 .else mov eax,false ret .endif mov eax,true ret optionproc endp searchproc proc hwnd:dword, umsg:dword, wparam:dword, lparam:dword .if umsg==wm_initdialog push hwnd pop hsearch invoke checkradiobutton,hwnd,idc_down,idc_up,idc_down invoke senddlgitemmessage,hwnd,idc_findedit,wm_settext,0,addr findbuffer .elseif umsg==wm_command mov eax,wparam shr eax,16 .if ax==bn_clicked mov eax,wparam .if ax==idok mov uflags,0 invoke sendmessage,hwndrichedit,em_exgetsel,0,addr findtext.chrg invoke getdlgitemtext,hwnd,idc_findedit,addr findbuffer,sizeof findbuffer .if eax!=0 invoke isdlgbuttonchecked,hwnd,idc_down .if eax==bst_checked or uflags,fr_down mov eax,findtext.chrg.cpmin .if eax!=findtext.chrg.cpmax push findtext.chrg.cpmax pop findtext.chrg.cpmin .endif mov findtext.chrg.cpmax,-1 .else mov findtext.chrg.cpmax,0 .endif invoke isdlgbuttonchecked,hwnd,idc_matchcase .if eax==bst_checked or uflags,fr_matchcase .endif invoke isdlgbuttonchecked,hwnd,idc_wholeword .if eax==bst_checked or uflags,fr_wholeword .endif mov findtext.lpstrtext,offset findbuffer invoke sendmessage,hwndrichedit,em_findtextex,uflags,addr findtext .if eax!=-1 invoke sendmessage,hwndrichedit,em_exsetsel,0