📄 masmed.asm
字号:
mov eax,rect.right
sub eax,50
mov max,eax
mov min,50
mov eax,pt.x
sub eax,rect.right
neg eax
.if sdword ptr eax>max
mov eax,max
.endif
.if sdword ptr eax<min
mov eax,min
.endif
.if eax!=wpos.wtfile
mov wpos.wtfile,eax
invoke SendMessage,hWin,WM_SIZE,0,0
invoke UpdateWindow,hREd
invoke UpdateWindow,hOut
.endif
.endif
.elseif eax==WM_SIZE
;Get size of windows client area
invoke GetClientRect,hWin,addr rect
invoke GetDlgItem,hWin,IDC_SHP
mov hCtl,eax
test wpos.fView,1
.if !ZERO?
;Resize toolbar
.if lParam
invoke MoveWindow,hCtl,0,0,rect.right,27,TRUE
invoke ShowWindow,hCtl,SW_SHOW
invoke GetDlgItem,hWin,IDC_TBR
mov hCtl,eax
mov eax,rect.right
sub eax,4
invoke MoveWindow,hCtl,2,2,eax,23,TRUE
invoke ShowWindow,hCtl,SW_SHOW
.endif
mov eax,27
.else
invoke ShowWindow,hCtl,SW_HIDE
invoke GetDlgItem,hWin,IDC_TBR
invoke ShowWindow,eax,SW_HIDE
xor eax,eax
.endif
push eax
invoke GetDlgItem,hWin,IDC_SBR
mov hCtl,eax
test wpos.fView,2
.if !ZERO?
;Resize statusbar
.if lParam
mov eax,rect.bottom
sub eax,21
invoke MoveWindow,hCtl,0,eax,rect.right,21,TRUE
invoke ShowWindow,hCtl,SW_SHOW
.endif
;Get height of statusbar
invoke GetWindowRect,hCtl,addr tmprect
mov eax,tmprect.bottom
sub eax,tmprect.top
.else
invoke ShowWindow,hCtl,SW_HIDE
xor eax,eax
.endif
push eax
;Get size of windows client area
invoke GetClientRect,hWin,addr rect
;Subtract height of statusbar from bottom
pop eax
sub rect.bottom,eax
;Add height of toolbar to top
pop eax
add rect.top,eax
.if lParam
;Resize tab window
mov edx,rect.right
sub edx,CBOWT
push edx
inc edx
invoke MoveWindow,hTab,-1,rect.top,edx,TABHT,TRUE
invoke UpdateWindow,hTab
pop edx
;Resize combobox
mov eax,rect.right
sub eax,edx
invoke MoveWindow,hCbo,edx,rect.top,eax,CBOWT,TRUE
invoke UpdateWindow,hCbo
.endif
;Add height of tab window to top
add rect.top,TABHT
test wpos.fView,8
.if !ZERO?
;Resize file browser
mov eax,wpos.wtfile
sub rect.right,eax
mov edx,rect.bottom
sub edx,rect.top
mov ecx,rect.right
add ecx,RESIZEHT
sub eax,RESIZEHT
invoke MoveWindow,hBrowse,ecx,rect.top,eax,edx,TRUE
.endif
test wpos.fView,4
.if !ZERO?
;Subtract height of resize from bottom
sub rect.bottom,RESIZEHT
;Subtract height of output from bottom
mov eax,wpos.htout
sub rect.bottom,eax
.endif
;Get new height of RAEdit window
mov eax,rect.bottom
sub eax,rect.top
mov ht,eax
;Resize RAEdit window
invoke MoveWindow,hREd,0,rect.top,rect.right,ht,TRUE
test wpos.fView,4
.if !ZERO?
mov eax,ht
add eax,RESIZEHT
add rect.top,eax
;Resize Output window
invoke MoveWindow,hOut,0,rect.top,rect.right,wpos.htout,TRUE
invoke UpdateWindow,hOut
invoke ShowWindow,hOut,SW_SHOW
.else
invoke ShowWindow,hOut,SW_HIDE
.endif
.elseif eax==WM_INITDIALOG
push hWin
pop hWnd
invoke MoveWindow,hWin,wpos.x,wpos.y,wpos.wt,wpos.ht,TRUE
mov fr,FR_DOWN
invoke LoadCursor,hInstance,IDC_HSPLIT
mov hHSplitCur,eax
invoke LoadCursor,hInstance,IDC_VSPLIT
mov hVSplitCur,eax
;Set the toolbar buttons
invoke GetDlgItem,hWin,IDC_TBR
invoke DoToolBar,hInstance,eax
;Set FileName to NewFile
invoke lstrcpy,offset FileName,offset szNewFile
invoke SetWinCaption,offset FileName
;Create line number font
invoke CreateFontIndirect,offset lfntlnr
mov hLnrFont,eax
;Create normal font
invoke CreateFontIndirect,offset lfnt
mov hFont,eax
mov al,lfnt.lfItalic
push eax
;Create italics font
mov lfnt.lfItalic,TRUE
invoke CreateFontIndirect,offset lfnt
mov hIFont,eax
pop eax
mov lfnt.lfItalic,al
;Create output window
invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szRAEditClass,NULL,WS_CHILD or WS_VISIBLE or STYLE_NOSPLITT or STYLE_NOLINENUMBER or STYLE_NOCOLLAPSE or STYLE_NOHILITE or STYLE_NOBACKBUFFER or STYLE_DRAGDROP or STYLE_SCROLLTIP or STYLE_NOSTATE,0,0,0,0,hWnd,IDC_OUT,hInstance,0
mov hOut,eax
invoke SendMessage,hOut,WM_SETFONT,hFont,FALSE
invoke CreateRAEdit
;Set hilite words
invoke SetKeyWords
;Set colors
invoke SendMessage,hREd,REM_SETCOLOR,0,addr col
;and give it focus
invoke SetFocus,hREd
;Get handle of tab window
invoke GetDlgItem,hWin,IDC_TAB
mov hTab,eax
invoke TabToolAdd,hREd,offset FileName
invoke GetMenu,hWin
mov hMnu,eax
invoke GetDlgItem,hWin,IDC_TBR
mov hTbr,eax
invoke GetDlgItem,hWin,IDC_CBO
mov hCbo,eax
invoke ImageList_Create,16,16,ILC_COLOR4 or ILC_MASK,4,0
mov hMnuIml,eax
invoke LoadBitmap,hInstance,IDB_MNUARROW
push eax
invoke ImageList_AddMasked,hMnuIml,eax,0C0C0C0h
pop eax
invoke DeleteObject,eax
invoke SetToolMenu
invoke SetHelpMenu
invoke CreateWindowEx,0,addr szFBClassName,0,WS_CHILD or WS_VISIBLE or WS_CLIPSIBLINGS or WS_CLIPCHILDREN or FBSTYLE_FLATTOOLBAR,0,0,0,0,hWin,IDC_FILE,hInstance,0
mov hBrowse,eax
invoke SendDlgItemMessage,hWin,IDC_SBR,WM_GETFONT,0,0
push eax
invoke SendMessage,hBrowse,WM_SETFONT,eax,FALSE
pop eax
invoke CreateWindowEx,0,addr szResClassName,0,WS_CHILD or WS_VISIBLE or WS_CLIPSIBLINGS or WS_CLIPCHILDREN,0,0,0,0,hWin,IDC_RES,hInstance,eax
mov hRes,eax
;Add custom controls
mov nInx,1
mov ebx,offset hCustDll
.while nInx<=32
invoke MakeKey,addr szCust,nInx,addr buffer1
mov lpcbData,MAX_PATH
mov buffer,0
invoke RegQueryValueEx,hReg,addr buffer1,0,addr lpType,addr buffer,addr lpcbData
.if buffer
invoke SendMessage,hResEd,DEM_ADDCONTROL,0,addr buffer
.if eax
mov [ebx],eax
add ebx,4
.endif
.endif
inc nInx
.endw
invoke CreateCodeComplete
invoke UpdateToolColors
invoke SendMessage,hBrowse,FBM_SETFILTERSTRING,FALSE,addr szFilter
invoke SendMessage,hBrowse,FBM_SETFILTER,FALSE,TRUE
invoke GetModuleFileName,0,addr buffer,sizeof buffer
invoke SetCurDir,addr buffer,TRUE
invoke SetTimer,hWin,200,200,addr MyTimerProc
mov fTimer,1
.elseif eax==WM_COMMAND
;Menu and toolbar has the same ID's
mov eax,wParam
mov edx,eax
movzx eax,ax
shr edx,16
.if edx==BN_CLICKED || edx==CBN_SELCHANGE
.if eax==IDM_FILE_NEW
invoke CreateNew
mov fTimer,1
.elseif eax==IDM_FILE_NEW_RES
invoke CreateNewRes
mov fTimer,1
.elseif eax==IDM_FILE_OPEN
invoke OpenEdit
mov fTimer,1
.elseif eax==IDM_FILE_OPEN_HEX
invoke OpenHex
mov fTimer,1
.elseif eax==IDM_FILE_SAVE
invoke SaveEdit,hREd,offset FileName
invoke SetFocus,hREd
.elseif eax==IDM_FILE_SAVEALL
invoke UpdateAll,SAVE_ALL
.elseif eax==IDM_FILE_SAVEAS
invoke SaveEditAs,hREd,offset FileName
.elseif eax==IDM_FILE_CLOSE
invoke WantToSave,hREd,offset FileName
.if !eax
mov eax,hREd
.if eax!=hRes
invoke DestroyWindow,eax
.endif
invoke TabToolDel,hREd
.endif
mov fTimer,1
.elseif eax==IDM_FILE_CLOSE_ALL
invoke UpdateAll,WM_CLOSE
.if !eax
invoke CloseNotify
invoke UpdateAll,CLOSE_ALL
invoke CreateNew
.endif
mov fTimer,1
.elseif eax==IDM_FILE_PAGESETUP
invoke GetPrnCaps
mov psd.lStructSize,sizeof psd
mov eax,hWin
mov psd.hwndOwner,eax
mov eax,hInstance
mov psd.hInstance,eax
.if prnInches
mov eax,PSD_MARGINS or PSD_INTHOUSANDTHSOFINCHES
.else
mov eax,PSD_MARGINS or PSD_INHUNDREDTHSOFMILLIMETERS
.endif
mov psd.Flags,eax
invoke PageSetupDlg,addr psd
.if eax
mov eax,psd.rtMargin.left
mov ppos.margins.left,eax
mov eax,psd.rtMargin.top
mov ppos.margins.top,eax
mov eax,psd.rtMargin.right
mov ppos.margins.right,eax
mov eax,psd.rtMargin.bottom
mov ppos.margins.bottom,eax
mov eax,psd.ptPaperSize.x
mov ppos.pagesize.x,eax
mov eax,psd.ptPaperSize.y
mov ppos.pagesize.y,eax
invoke RegSetValueEx,hReg,addr szPrnPos,0,REG_BINARY,addr ppos,sizeof ppos
.endif
.elseif eax==IDM_FILE_PRINT
mov pd.lStructSize,sizeof pd
mov eax,hWin
mov pd.hwndOwner,eax
mov eax,hInstance
mov pd.hInstance,eax
invoke SendMessage,hREd,EM_GETLINECOUNT,0,0
inc eax
mov ecx,ppos.nlinespage
.if !ecx
mov ecx,66
.endif
xor edx,edx
div ecx
.if edx
inc eax
.endif
mov pd.nMinPage,1
mov pd.nMaxPage,ax
mov pd.nFromPage,1
mov pd.nToPage,ax
invoke SendMessage,hREd,EM_EXGETSEL,0,addr chrg
mov eax,chrg.cpMin
.if eax!=chrg.cpMax
mov eax,PD_RETURNDC or PD_SELECTION
.else
mov eax,PD_RETURNDC or PD_NOSELECTION; or PD_PAGENUMS
.endif
mov pd.Flags,eax
invoke PrintDlg,addr pd
.if eax
invoke Print
.endif
.elseif eax==IDM_FILE_EXIT
invoke SendMessage,hWin,WM_CLOSE,0,0
.elseif eax==IDM_EDIT_UNDO
invoke SendMessage,hREd,EM_UNDO,0,0
.elseif eax==IDM_EDIT_REDO
invoke SendMessage,hREd,EM_REDO,0,0
.elseif eax==IDM_EDIT_DELETE
invoke SendMessage,hREd,WM_CLEAR,0,0
.elseif eax==IDM_EDIT_CUT
invoke SendMessage,hREd,WM_CUT,0,0
.elseif eax==IDM_EDIT_COPY
invoke SendMessage,hREd,WM_COPY,0,0
.elseif eax==IDM_EDIT_PASTE
invoke SendMessage,hREd,WM_PASTE,0,0
.elseif eax==IDM_EDIT_SELECTALL
mov chrg.cpMin,0
mov chrg.cpMax,-1
invoke SendMessage,hREd,EM_EXSETSEL,0,addr chrg
.elseif eax==IDM_EDIT_FIND
.if !hFind
invoke GetWindowLong,hREd,GWL_ID
.if eax==IDC_RAE
invoke GetSelText,offset findbuff
invoke CreateDialogParam,hInstance,IDD_FINDDLG,hWin,offset FindDlgProc,FALSE
.elseif eax==IDC_HEX
invoke CreateDialogParam,hInstance,IDD_HEXFINDDLG,hWin,offset HexFindDlgProc,FALSE
.endif
.else
invoke SetFocus,hFind
.endif
.elseif eax==IDM_EDIT_REPLACE
.if !hFind
invoke GetWindowLong,hREd,GWL_ID
.if eax==IDC_RAE
invoke GetSelText,offset findbuff
invoke CreateDialogParam,hInstance,IDD_FINDDLG,hWin,addr FindDlgProc,TRUE
.elseif eax==IDC_HEX
invoke CreateDialogParam,hInstance,IDD_HEXFINDDLG,hWin,offset HexFindDlgProc,TRUE
.endif
.else
invoke SetFocus,hFind
.endif
.elseif eax==IDM_EDIT_FINDNEXT
.if !hFind
invoke GetSelText,offset findbuff
.endif
invoke GetWindowLong,hREd,GWL_ID
.if eax==IDC_RAE
mov al,findbuff
.if al
invoke Find,FR_DOWN
.endif
.elseif eax==IDC_HEX
mov al,findbuff
.if al
invoke HexFind,FR_DOWN or FR_HEX
.endif
.endif
.elseif eax==IDM_EDIT_FINDPREV
.if !hFind
invoke GetSelText,offset findbuff
.endif
invoke GetWindowLong,hREd,GWL_ID
.if eax==IDC_RAE
mov al,findbuff
.if al
invoke Find,0
.endif
.elseif eax==IDC_HEX
mov al,findbuff
.if al
invoke HexFind,FR_HEX
.endif
.endif
.elseif eax==IDM_EDIT_INDENT
invoke IndentComment,VK_TAB,TRUE
.elseif eax==IDM_EDIT_OUTDENT
invoke IndentComment,VK_TAB,FALSE
.elseif eax==IDM_EDIT_COMMENT
invoke IndentComment,';',TRUE
.elseif eax==IDM_EDIT_UNCOMMENT
invoke IndentComment,';',FALSE
.elseif eax==IDM_EDIT_BLOCKMODE
invoke SendMessage,hREd,REM_GETMODE,0,0
xor eax,MODE_BLOCK
invoke SendMessage,hREd,REM_SETMODE,eax,0
mov fTimer,1
.elseif eax==IDM_EDIT_BLOCKINSERT
invoke CreateDialogParam,hInstance,IDD_BLOCKDLG,hWin,addr BlockDlgProc,0
.elseif eax==IDM_EDIT_TOGGLEBM
invoke GetWindowLong,hREd,GWL_ID
.if eax==IDC_RAE
invoke SendMessage,hREd,EM_EXGETSEL,0,addr chrg
invoke SendMessage,hREd,EM_EXLINEFROMCHAR,0,chrg.cpMin
mov ebx,eax
invoke SendMessage,hREd,REM_GETBOOKMARK,ebx,0
.if !eax
invoke SendMessage,hREd,REM_SETBOOKMARK,ebx,3
.elseif eax==3
invoke SendMessage,hREd,REM_SETBOOKMARK,ebx,0
.endif
.elseif eax==IDC_HEX
invoke SendMessage,hREd,EM_EXGETSEL,0,addr chrg
mov eax,chrg.cpMin
shr eax,5
invoke SendMessage,hREd,HEM_TOGGLEBOOKMARK,eax,0
.endif
mov fTimer,1
.elseif eax==IDM_EDIT_NEXTBM
invoke GetWindowLong,hREd,GWL_ID
.if eax==IDC_RAE
invoke SendMessage,hREd,EM_EXGETSEL,0,addr chrg
invoke SendMessage,hREd,EM_EXLINEFROMCHAR,0,chrg.cpMin
invoke SendMessage,hREd,REM_NXTBOOKMARK,eax,3
.if eax!=-1
invoke SendMessage,hREd,EM_LINEINDEX,eax,0
mov chrg.cpMin,eax
mov chrg.cpMax,eax
invoke SendMessage,hREd,EM_EXSETSEL,0,addr chrg
invoke SendMessage,hREd,EM_SCROLLCARET,0,0
.endif
.elseif eax==IDC_HEX
invoke SendMessage,hREd,HEM_NEXTBOOKMARK,0,addr hebmk
.if eax
invoke TabToolGetInx,hebmk.hWin
invoke SendMessage,hTab,TCM_SETCURSEL,eax,0
invoke TabToolActivate
mov eax,hebmk.nLine
shl eax,5
mov chrg.cpMin,eax
mov chrg.cpMax,eax
invoke SendMessage,hREd,EM_EXSETSEL,0,addr chrg
invoke SendMessage,hREd,HEM_VCENTER,0,0
.endif
.endif
.elseif eax==IDM_EDIT_PREVBM
invoke GetWindowLong,hREd,GWL_ID
.if eax==IDC_RAE
invoke SendMessage,hREd,EM_EXGETSEL,0,addr chrg
invoke SendMessage,hREd,EM_EXLINEFROMCHAR,0,chrg.cpMin
invoke SendMessage,hREd,REM_PRVBOOKMARK,eax,3
.if eax!=-1
invoke SendMessage,hREd,EM_LINEINDEX,eax,0
mov chrg.cpMin,eax
mov chrg.cpMax,eax
invoke SendMessage,hREd,EM_EXSETSEL,0,addr chrg
invoke SendMessage,hREd,EM_SCROLLCARET,0,0
.endif
.elseif eax==IDC_HEX
invoke SendMessage,hREd,HEM_PREVIOUSBOOKMARK,0,addr hebmk
.if eax
invoke TabToolGetInx,hebmk.hWin
invoke SendMessage,hTab,TCM_SETCURSEL,eax,0
invoke TabToolActivate
mov eax,hebmk.nLine
shl eax,5
mov chrg.cpMin,eax
mov chrg.cpMax,eax
invoke SendMessage,hREd,EM_EXSETSEL,0,addr chrg
invoke SendMessage,hREd,HEM_VCENTER,0,0
.endif
.endif
.elseif eax==IDM_EDIT_CLEARBM
invoke GetWindowLong,hREd,GWL_ID
.if eax==IDC_RAE
invoke SendMessage,hREd,REM_CLRBOOKMARKS,0,3
.elseif eax==IDC_HEX
invoke SendMessage,hREd,HEM_CLEARBOOKMARKS,0,0
.endif
mov fTimer,1
.elseif eax==IDM_FORMAT_LOCK
invoke SendMessage,hResEd,DEM_ISLOCKED,0,0
xor eax,TRUE
invoke SendMessage,hResEd,DEM_LOCKCONTROLS,0,eax
.elseif eax==IDM_FORMAT_BACK
invoke SendMessage,hResEd,DEM_SENDTOBACK,0,0
.elseif eax==IDM_FORMAT_FRONT
invoke SendMessage,hResEd,DEM_BRINGTOFRONT,0,0
.elseif eax==IDM_FORMAT_GRID
invoke GetWindowLong,hResEd,GWL_STYLE
xor eax,DES_GRID
invoke SetWindowLong,hResEd,GWL_STYLE,eax
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -