📄 jsb.asm
字号:
mov eax,wParam
.if ax==IDC_CANCEL
invoke SendMessage,hWin,WM_CLOSE,0,0
.elseif ax==IDC_GOTO
invoke GetDlgItemInt,hWin,IDC_GOTOLINEEDIT,NULL,FALSE
mov LineNo,eax
invoke SendMessage,hREd,EM_GETLINECOUNT,0,0
.if eax>LineNo
invoke SendMessage,hREd,EM_LINEINDEX,LineNo,0
invoke SendMessage,hREd,EM_SETSEL,eax,eax
invoke SendMessage,hWin,WM_CLOSE,0,0
invoke SetFocus,hREd
.endif
.endif
.endif
.elseif uMsg==WM_CLOSE
mov hFind,0
invoke EndDialog,hWin,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
GotoDlgProc endp
_PrintDc proc uses ebx esi edi
local @PrintSize
local @Doc : DOCINFO
invoke CreateDC,NULL,offset szPrinter,NULL,NULL
mov hDc,eax
.if hDc
.if szPrinter
invoke GetWindowTextLength,hREd
inc eax
mov @PrintSize,eax
invoke GetProcessHeap
.if eax && (eax < 0C0000000H)
mov hHeap2,eax
.endif
invoke HeapAlloc,hHeap2,HEAP_GENERATE_EXCEPTIONS or HEAP_NO_SERIALIZE or\
HEAP_ZERO_MEMORY,@PrintSize
.if eax && (eax < 0c0000000h)
mov lpPrintBuffer,eax
.endif
invoke GetWindowText,hREd,lpPrintBuffer,@PrintSize
invoke StartDoc,hDc,NULL
invoke StartPage,hDc
invoke TextOut,hDc,10,10,lpPrintBuffer,@PrintSize
invoke EndPage,hDc
invoke EndDoc,hDc
invoke HeapFree,hHeap2,NULL,lpPrintBuffer
invoke RtlZeroMemory,offset szPrinter,sizeof szPrinter
.endif
.endif
ret
_PrintDc endp
WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL pt:POINT
LOCAL rect:RECT
LOCAL ht:DWORD
LOCAL hCtl:HWND
LOCAL chrg:CHARRANGE
LOCAL cf:CHOOSEFONT
LOCAL @szBuffer[128]:byte
LOCAL @stST:SYSTEMTIME
LOCAL @stTime:SYSTEMTIME
LOCAL @pt:POINT
LOCAL @rect:RECT
LOCAL @stPS:POINT
LOCAL @KeyState[256]:byte
mov eax,uMsg
.if eax==WM_INITDIALOG
push hWin
pop hWnd
mov fView,3
mov TabSize,4
;Set the toolbar buttons
invoke GetDlgItem,hWin,IDC_TBR
invoke DoToolBar,hInstance,eax
;Set FileName to NewFile
invoke lstrcpy,addr FileName,addr NewFile
invoke SetWinCaption
;Get handle of RichEdit window and give it focus
invoke GetDlgItem,hWin,IDC_RED
mov hREd,eax
invoke _SetStatus
invoke SendMessage,hREd,EM_SETTEXTMODE,0,TM_PLAINTEXT ;和MSN上解释不一样
;Set event mask
invoke SendMessage,hREd,EM_SETEVENTMASK,0,ENM_SELCHANGE or ENM_CHANGE or ENM_MOUSEEVENTS or ENM_KEYEVENTS
;invoke SendMessage,hREd,EM_SETEVENTMASK,0,ENM_MOUSEEVENTS
;Set the text limit. The default is 64K
invoke SendMessage,hREd,EM_LIMITTEXT,-1,0
;Create font
invoke lstrcpy,addr lfnt.lfFaceName,offset szFont
mov lfnt.lfHeight,-12
mov lfnt.lfWeight,400
invoke CreateFontIndirect,addr lfnt
mov hFont,eax
;Set font & format
invoke SetFormat,hREd
;Init RichEdit
invoke SendMessage,hREd,EM_SETMODIFY,FALSE,0
invoke SendMessage,hREd,EM_EMPTYUNDOBUFFER,0,0
invoke SetFocus,hREd
invoke GetDlgItem,hWin,IDC_SBR ;获得状态栏的句柄
mov hWinStatus,eax
invoke SendMessage,hWinStatus,SB_SETPARTS,6,offset dwStatusWidth ;进行分割
mov lpsz1,offset szStatus1
mov lpsz2,offset szStatus2
invoke SendMessage,hWinStatus,SB_SETTEXT,4,lpsz1;设置文字
invoke SetTimer,hWin,1,300,NULL
;invoke EnableMenuItem,hMenu,IDM_FILE_PRINT,MF_GRAYED
invoke GetMenu,hWnd
mov hMenu,eax
invoke GetDlgItem,hWnd,IDC_TBR
mov hTbr,eax
.elseif eax==WM_TIMER ;在状态栏上显示系统时间
invoke GetLocalTime,addr @stST
movzx eax,@stST.wHour
movzx ebx,@stST.wMinute
movzx ecx,@stST.wSecond
invoke wsprintf,addr @szBuffer,addr szTimeFormat,eax,ebx,ecx
invoke SendMessage,hWinStatus,SB_SETTEXT,5,addr @szBuffer
.elseif eax==WM_COMMAND
;Menu and toolbar has the same ID's
mov eax,wParam
and eax,0FFFFh
.if eax==IDM_FILE_NEW
invoke WantToSave
.if !eax
invoke SetWindowText,hREd,addr szNULL
invoke lstrcpy,addr FileName,addr NewFile
invoke SetWinCaption
invoke _SetStatus
.endif
invoke SetFocus,hREd
.elseif eax==IDM_FILE_OPEN
invoke WantToSave
.if !eax
invoke OpenEdit
.endif
invoke SetFocus,hREd
.elseif eax==IDM_FILE_SAVE
invoke SaveEdit
invoke SetFocus,hREd
.elseif eax==IDM_FILE_SAVEAS
invoke SaveEditAs
invoke SetFocus,hREd
.elseif eax==IDM_PAGESET
call _PAGESET
.elseif eax==IDM_FILE_PRINT
call _PrintDc
.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,EM_REPLACESEL,TRUE,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==0
invoke CreateDialogParam,hInstance,IDD_FINDDLG,hWin,addr FindDlgProc,FALSE
.else
invoke SetFocus,hFind
.endif
.elseif eax==IDM_EDIT_REPLACE
.if hFind==0
invoke CreateDialogParam,hInstance,IDD_FINDDLG,hWin,addr FindDlgProc,FALSE
.else
invoke SetFocus,hFind
.endif
.elseif eax==IDM_EDIT_GOTO
.if hFind==0
invoke CreateDialogParam,hInstance,IDD_GOTODLG,hWin,addr GotoDlgProc,FALSE
.else
invoke SetFocus,hFind
.endif
.elseif eax==IDM_EDIT_FINDNEXT
invoke lstrlen,addr szFindText
.if eax!=0
invoke SendMessage,hREd,EM_EXGETSEL,0,addr stFindText.chrg
mov eax,stFindText.chrg.cpMin
.if eax!=stFindText.chrg.cpMax
push stFindText.chrg.cpMax
pop stFindText.chrg.cpMin
.endif
mov stFindText.chrg.cpMax,-1
mov stFindText.lpstrText,offset szFindText
invoke SendMessage,hREd,EM_FINDTEXTEX,FR_DOWN,addr stFindText
.if eax!=-1
invoke SendMessage,hREd,EM_EXSETSEL,0,addr stFindText.chrgText
.endif
.endif
.elseif eax==IDM_EDIT_FINDPREV
invoke lstrlen,addr szFindText
.if eax!=0
invoke SendMessage,hREd,EM_EXGETSEL,0,addr stFindText.chrg
mov stFindText.chrg.cpMax,0
mov stFindText.lpstrText,offset szFindText
invoke SendMessage,hREd,EM_FINDTEXTEX,0,addr stFindText
.if eax!=-1
invoke SendMessage,hREd,EM_EXSETSEL,0,addr stFindText.chrgText
.endif
.endif
.elseif eax==IDM_DATE
invoke GetLocalTime,addr @stTime
movzx eax,@stTime.wYear
movzx ebx,@stTime.wMonth
movzx ecx,@stTime.wDay
invoke wsprintf,addr @szBuffer,addr szDate,eax,ebx,ecx
invoke SendMessage,hREd,EM_REPLACESEL,TRUE,addr @szBuffer;插入日期
.elseif eax==IDM_VIEW_TOOLBAR
invoke GetDlgItem,hWin,IDC_TBR
mov hCtl,eax
xor fView,1
mov eax,fView
and eax,1
.if eax
invoke ShowWindow,hCtl,SW_SHOWNA
.else
invoke ShowWindow,hCtl,SW_HIDE
.endif
invoke SendMessage,hWin,WM_SIZE,0,0
.elseif eax==IDM_VIEW_STATUSBAR
invoke GetDlgItem,hWin,IDC_SBR
mov hCtl,eax
xor fView,2
mov eax,fView
and eax,2
.if eax
invoke ShowWindow,hCtl,SW_SHOWNA
.else
invoke ShowWindow,hCtl,SW_HIDE
.endif
invoke SendMessage,hWin,WM_SIZE,0,0
.elseif eax==IDM_OPTION_FONT
call _ChooseFont
invoke SetFocus,hREd
.elseif eax==IDM_BACKCOLOR
invoke _ChooseColor
.elseif eax==IDM_UPSIGN
invoke _SetFormat,hREd,TRUE
.elseif eax==IDM_DOWNSIGN
invoke _SetFormat,hREd,FALSE
.elseif eax==IDM_HELP_ABOUT
invoke ShellAbout,hWin,addr AppName,addr AboutMsg,hIcon
invoke SetFocus,hREd
.endif
.elseif eax==WM_NOTIFY
mov eax,lParam
mov eax,[eax+NMHDR.hwndFrom]
.if eax==hREd
invoke _SetStatus
.endif
pushad ;处理右键功能
mov esi,lParam
assume esi:ptr NMHDR
.if [esi].code==EN_MSGFILTER
assume esi:ptr MSGFILTER
.if [esi].msg==WM_RBUTTONDOWN
invoke GetSubMenu,hMenu,1 ;获得子菜单句柄
mov hSubMenu, eax
mov edx,[esi].lParam
mov ecx,edx
and edx,0ffffh
shr ecx,16
mov @stPS.x,edx
mov @stPS.y,ecx
invoke ClientToScreen,hWnd,addr @stPS
invoke TrackPopupMenu,hSubMenu,TPM_LEFTALIGN or TPM_RIGHTALIGN,@stPS.x,@stPS.y,NULL,hWnd,NULL
.elseif [esi].msg==WM_KEYDOWN
mov eax,wParam
.if eax==VK_INSERT
mov eax,lpsz1
xchg eax,lpsz2
mov lpsz1,eax
invoke SendMessage,hWinStatus,SB_SETTEXT,4,lpsz1
.endif
.endif
popad
.endif
.if wParam==IDC_SBR ;状态栏上"插入"与"改写"的更换
mov eax,lParam
mov eax,[eax+NMHDR.code]
.if eax==NM_CLICK
invoke GetCursorPos,addr @pt
invoke GetWindowRect,hWinStatus,addr @rect
mov eax,@rect.left
mov ecx,eax
add eax,300
add ecx,350
.if ( @pt.x>= eax) && ( @pt.x <= ecx) ;状态栏设置的位置区域
mov eax,lpsz1
xchg eax,lpsz2
mov lpsz1,eax
invoke SendMessage,hWinStatus,SB_SETTEXT,4,lpsz1
invoke SendMessage,hREd,WM_KEYDOWN,VK_INSERT,24 ;向编辑框发送消息
.endif
.endif
.elseif wParam==IDC_RED
;Auto horizontal scroll text into view
invoke GetCaretPos,addr pt
invoke GetClientRect,hREd,addr rect
mov eax,rect.right
sub eax,pt.x
.if eax<20
;Caret near right edge
invoke SendMessage,hREd,EM_GETSCROLLPOS,0,addr pt
add pt.x,70
invoke SendMessage,hREd,EM_SETSCROLLPOS,0,addr pt
.endif
.endif
.elseif eax==WM_KEYDOWN ;处理消息
mov eax,wParam
.if eax==VK_INSERT
mov eax,lpsz1
xchg eax,lpsz2
mov lpsz1,eax
invoke SendMessage,hWinStatus,SB_SETTEXT,4,lpsz1
.endif
.elseif eax==WM_INITMENU
invoke _SetStatus
.elseif eax==WM_SIZE
mov eax,fView
and eax,1
.if eax
;Resize toolbar
invoke GetDlgItem,hWin,IDC_TBR
mov hCtl,eax
invoke MoveWindow,hCtl,0,0,0,0,TRUE
;Get height of toolbar
invoke GetWindowRect,hCtl,addr rect
mov eax,rect.bottom
sub eax,rect.top
.endif
push eax
mov eax,fView
and eax,2
.if eax
;Resize statusbar
invoke GetDlgItem,hWin,IDC_SBR
mov hCtl,eax
invoke MoveWindow,hCtl,0,0,0,0,TRUE
;Get height of statusbar
invoke GetWindowRect,hCtl,addr rect
mov eax,rect.bottom
sub eax,rect.top
.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
;Get new height of RichEdit window
mov eax,rect.bottom
sub eax,rect.top
mov ht,eax
;Resize RichEdit window
invoke MoveWindow,hREd,0,rect.top,rect.right,ht,TRUE
.elseif eax==WM_CLOSE
invoke WantToSave
.if !eax
invoke KillTimer,hWin,1
invoke DestroyWindow,hWin
.endif
.elseif eax==WM_DESTROY
invoke DeleteObject,hFont
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -