⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notepro.asm

📁 一个简单的记事本
💻 ASM
📖 第 1 页 / 共 5 页
字号:
				.if WhichTabChosen == 0
					INVOKE ShowWindow,hChild1,SW_SHOWDEFAULT
					INVOKE ShowWindow,hChild2,SW_HIDE
				.else
					INVOKE ShowWindow,hChild2,SW_SHOWDEFAULT
					INVOKE ShowWindow,hChild1,SW_HIDE
				.endif
			.endif
		.elseif eax == WM_COMMAND
			mov ebx,wParam
			movzx ebx,bx
			.if ebx == IDOK
				invoke _GetChild1Status
				invoke  EndDialog,hWnd,0
			.elseif ebx == IDCANCEL
				invoke  EndDialog,hWnd,0
			.endif
		.elseif eax == WM_CLOSE
			invoke  EndDialog,hWnd,0
		.else
			mov eax,FALSE
		.endif
		ret
_ProcOptionDlg	endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcChild1	proc	uses ebx edi esi,hWnd,uMsg,wParam,lParam
	mov eax,uMsg
	.if eax == WM_INITDIALOG
		mov	eax,hWnd
		mov	hChild1,eax
		invoke _SetChild1Status
	.endif
	xor eax,eax
	ret
_ProcChild1	endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcChild2	proc	uses ebx edi esi,hWnd,uMsg,wParam,lParam
	mov eax,uMsg
	xor eax,eax
	ret
_ProcChild2	endp
;>>>>>>>>>>>>>>>>>>>>>打开文件对话框的勾子过程>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_OFNHookProcTxt proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
	local  @szFilePath[MAX_PATH]	:BYTE
	local  @hFile				:DWORD
	local  @hMem[1024]			:BYTE
	local  @nActualRead			:DWORD

	.if uMsg == WM_NOTIFY
		mov    eax,lParam
		mov    edi,eax
		assume edi:ptr NMHDR
		.if    [edi].code == CDN_INITDONE    ;对话框初始化完成后接到该消息
			invoke GetParent,hWnd
			mov    hDlgTxt, eax
			invoke GetDlgItem,hWnd,ID_PREVIEW
			mov    hPreView,eax
			invoke SendMessage,hPreView,WM_SETTEXT,0,addr szPreview

		.elseif [edi].code == CDN_SELCHANGE  ;选中了一个新的文件或文件夹
			invoke SendMessage,hDlgTxt,CDM_GETFILEPATH,MAX_PATH,addr @szFilePath
			invoke CreateFile,addr @szFilePath,GENERIC_READ,FILE_SHARE_READ, \
					NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL
			.if    eax == INVALID_HANDLE_VALUE
				xor eax, eax
				ret
			.endif
			mov    @hFile, eax
			invoke ReadFile,@hFile,addr @hMem,1024,addr @nActualRead,NULL
			invoke SendMessage,hPreView,WM_SETTEXT,0,addr @hMem
			invoke CloseHandle,@hFile
		.endif
	.endif
	xor  eax, eax
	ret
_OFNHookProcTxt endp
;>>>>>>>>>>>>>>>>>>>>>>>跳转对话框>>>>>>>>>>>>>>>>>>>>
_ProcGotoDlg	proc	uses ebx edi esi,hWnd,uMsg,wParam,lParam
	local @stRange		:CHARRANGE

		mov eax,uMsg
		.if eax == WM_COMMAND
			mov ebx,wParam
			movzx ebx,bx
			.if ebx == IDOK
				invoke GetDlgItemInt,hWnd,ID_LINETEXT,NULL,FALSE
				dec eax
				invoke SendMessage,hEdit,EM_LINEINDEX,eax,0
				.if eax != -1
					mov @stRange.cpMin,eax
					mov @stRange.cpMax,eax
					invoke SendMessage,hEdit,EM_EXSETSEL,0,addr @stRange
					invoke SendMessage,hEdit,EM_SCROLLCARET,0,0
				.else
					invoke MessageBox,hWnd,addr szLineError,NULL,MB_OK
				.endif
			.elseif ebx == IDCANCEL
				invoke  DestroyWindow,hWnd
			.endif
		.elseif eax == WM_CLOSE
			invoke  DestroyWindow,hWnd
		.elseif
			mov eax,FALSE
		.endif
		ret
_ProcGotoDlg	endp
;>>>>>>>>>>>>>>>>>>>>>>>关于本软件对话框的消息处理函数>>>>>>>>>>>>
_ProcSoftDlg	proc	uses ebx edi esi,hWnd,uMsg,wParam,lParam

		mov eax,uMsg
		.if eax == WM_COMMAND
			mov ebx,wParam
			movzx ebx,bx
			.if ebx == IDOK
				invoke  EndDialog,hWnd,0
			.endif
		.elseif eax == WM_CLOSE
			invoke  EndDialog,hWnd,0
		.else
			mov eax,FALSE
		.endif
		ret
_ProcSoftDlg	endp
;>>>>>>>>>>>>>>>>>>>>RichEdit的窗口处理函数>>>>>>>>>>>>>>>>>>>>>
_ProcRichEdit		proc uses ebx edi esi hWnd,uMsg,wParam,lParam
	local	@stPos		:POINT

	mov	eax,uMsg
	.if eax == WM_KEYDOWN
		invoke SendMessage,hWinMain,WM_KEYDOWN,wParam,lParam
	.elseif eax == WM_RBUTTONDOWN
		invoke	_ModifyTimeMenu
		invoke _SetMenuStatus
		invoke GetCursorPos,addr @stPos
		invoke GetSubMenu,hMenu,1
		invoke TrackPopupMenu,eax,TPM_LEFTALIGN,@stPos.x,@stPos.y,NULL,hWinMain,NULL
	.endif
	invoke CallWindowProc,lpOldProcRichEdit,hWnd,uMsg,wParam,lParam
	ret
_ProcRichEdit		endp
;>>>>>>>>>>>>>>>>>>>>>>主窗口处理函数>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcWinMain	proc	uses ebx edi esi,hWnd,uMsg,wParam,lParam
		local	@stRange	:CHARRANGE
		local	@stPos		:POINT
		local  @stPoint	:POINT
		local	@stRect	:RECT
		local	@dwCount	:DWORD


		mov	eax,uMsg
    		.if eax == WM_SIZE
			.if wParam == SIZE_MINIMIZED
				.if bTray
            				mov stNote.cbSize,sizeof stNote 
            				push hWnd 
            				pop stNote.hwnd 
            				mov stNote.uID,ID_TrayIcon 
            				mov stNote.uFlags,NIF_ICON+NIF_MESSAGE+NIF_TIP 
            				mov stNote.uCallbackMessage,WM_SHELLNOTIFY 
					invoke  LoadIcon,hInstance,ID_MainIcon 
            				mov 	stNote.hIcon,eax 
            				invoke lstrcpy,addr stNote.szTip,addr szCaptionMain 
            				invoke ShowWindow,hWnd,SW_HIDE 
            				invoke Shell_NotifyIcon,NIM_ADD,addr stNote
				.endif
			.else
				invoke _ResizeWindow
			.endif
    		.elseif eax == WM_SHELLNOTIFY ;自定义的托盘事件
        		.if wParam == ID_TrayIcon 
            			.if lParam==WM_RBUTTONDOWN
        				invoke CreatePopupMenu 
        				mov 	hTrayMenu,eax 
        				invoke AppendMenu,hTrayMenu,MF_STRING,IDM_RESTORE,addr szRestore 
        				invoke AppendMenu,hTrayMenu,MF_STRING,IDM_FILE_EXIT,addr szExit 
                			invoke GetCursorPos,addr @stPos 
                			invoke SetForegroundWindow,hWnd 
                			invoke TrackPopupMenu,hTrayMenu,TPM_RIGHTALIGN,@stPos.x,@stPos.y,NULL,hWnd,NULL 
                			invoke PostMessage,hWnd,WM_NULL,0,0 
            			.elseif lParam==WM_LBUTTONDBLCLK 
                			invoke SendMessage,hWnd,WM_COMMAND,IDM_RESTORE,0 
            			.endif 
        		.endif
    		.elseif eax == WM_DROPFILES	;FILE DROP
			invoke SetForegroundWindow,hWnd  ;把窗口拿到前台
			.if bDropped
        			invoke DragQueryFile,wParam,0,addr szBuffer2,sizeof szBuffer2
				invoke GetModuleFileName,NULL,addr szBuffer1,sizeof szBuffer1
				invoke lstrcat,addr szBuffer1,addr szCharBlank
				invoke lstrcat,addr szBuffer1,addr szBuffer2
				invoke WinExec,addr szBuffer1,SW_SHOW
			.else
				invoke	_CheckModify
				.if	eax
					.if	hFile
						invoke	CloseHandle,hFile
						mov	hFile,0
					.endif
					mov	szFileName,0
					invoke DragQueryFile,wParam,0,addr szFileName,sizeof szFileName
					invoke _OpenTheFile
				.endif
			.endif
    		.elseif eax == WM_SETFOCUS
        		invoke SetFocus,hEdit
		.elseif eax == WM_KEYDOWN
      			.if wParam == VK_F1
        			invoke SendMessage,hWnd,WM_COMMAND,IDM_HELP_SOFT,NULL
      			.elseif wParam == VK_ESCAPE && bEsc
        			invoke SendMessage,hWnd,WM_SYSCOMMAND,SC_CLOSE,NULL
			.else
				invoke GetKeyState,VK_INSERT
				.if eax<0;eax ==-127 || eax == -128
					xor bInsertFlag,1
				.endif
				invoke _SetStatusStatus
			.endif
		.elseif eax == WM_INITMENUPOPUP
			mov eax,lParam
			.if eax == 0	;选了文件菜单
				invoke _GetRecentlyFile
			.elseif eax == 1  ;选了编辑菜单
				invoke	_ModifyTimeMenu
			.endif
			invoke _SetMenuStatus
		.elseif eax == WM_MENUSELECT
			invoke MenuHelp,WM_MENUSELECT,wParam,lParam,\
				lParam,hInstance,hStatus,addr dwMenuHelp
		.elseif eax == WM_NOTIFY
			mov	ebx,lParam
			mov	eax,[ebx + NMHDR.hwndFrom]
			.if	[ebx + NMHDR.code] == TTN_NEEDTEXT
				assume	ebx:ptr TOOLTIPTEXT
				mov	eax,[ebx].hdr.idFrom
				mov	[ebx].lpszText,eax
				push	hInstance
				pop	[ebx].hInst
				assume	ebx:nothing
			.elseif  eax == hEdit
				invoke _SetToolStatus
				.if !bHasModifyFlag
					invoke	SendMessage,hEdit,EM_GETMODIFY,0,0
					.if eax
						invoke	_SetCaption
					.endif
				.endif
				invoke _SetStatusStatus
			.elseif eax == hStatus
				.if [ebx + NMHDR.code]== NM_CLICK
					invoke GetCursorPos,addr @stPoint
					invoke GetWindowRect,hStatus,addr @stRect
					mov	eax,@stRect.right
					sub	eax,208
					mov	@dwCount,0
					.repeat
						add eax,38
						mov ecx,eax
						add ecx,38
						inc @dwCount
					.until (@stPoint.x>=eax)&&(@stPoint.x<=ecx)||@dwCount>4
					mov eax,@dwCount
					.if eax == 1
						.if hFile
							.if bReadOnlyFlag
								invoke SetFileAttributes,addr szFileName,FILE_ATTRIBUTE_NORMAL
							.else
								invoke SetFileAttributes,addr szFileName,FILE_ATTRIBUTE_READONLY
							.endif
							invoke _SetToolStatus
							invoke _SetStatusStatus
						.endif
					.elseif eax ==2
						invoke keybd_event,VK_CAPITAL,45,0,0
						invoke _SetStatusStatus
					.elseif eax ==3
						invoke keybd_event,VK_CAPITAL,45,0,0
						invoke _SetStatusStatus
					.elseif eax ==4
						;invoke keybd_event,hEdit,WM_CHAR,65,0
						;invoke _SetStatusStatus
					.endif
				.endif
			.endif
		.elseif eax == WM_CREATE
			push	hWnd
			pop	hWinMain
			invoke  _Init
  		.elseif eax ==  WM_COMMAND
			.if lParam==0 ;;;这个参数还不懂!!!
            			invoke Shell_NotifyIcon,NIM_DELETE,addr stNote 
           		 	mov eax,wParam 
            			.if ax==IDM_RESTORE 
                			invoke ShowWindow,hWnd,SW_RESTORE 
            			.elseif ax == IDM_FILE_EXIT 
					invoke  SendMessage,hWnd,WM_CLOSE,0,0
           		 	.endif 
        		.endif
			mov	eax,wParam
			movzx	eax,ax
			.if	eax == IDM_FILE_NEW
				invoke	_CheckModify
				.if	eax
					.if	hFile
						invoke	CloseHandle,hFile
						mov	hFile,0
					.endif
					mov	szFileName,0
					invoke	SetWindowText,hEdit,NULL
					invoke	_SetCaption
				.endif
			.elseif eax == IDM_FILE_OPEN
				invoke _OpenFile
			.elseif eax == IDM_FILE_SAVE
				invoke _SaveFile
				invoke _SetCaption
			.elseif eax == IDM_FILE_SAVEAS
				invoke _SaveAs
			.elseif eax ==IDM_FILE_CREATE
				invoke GetModuleFileName,NULL,addr szBuffer1,sizeof szBuffer1
				invoke WinExec,addr szBuffer1,SW_SHOW
			.elseif eax == IDM_FILE_SETUP
				invoke _PageSetup
			.elseif eax == IDM_FILE_PRINT
				invoke _PrintText
			.elseif eax >= IDM_FILE_RECENT_FILE01 && eax <= IDM_FILE_RECENT_FILE10
				invoke	GetMenuString,hMenu,eax,addr szFileName,\
					sizeof szFileName,MF_BYCOMMAND
				invoke _OpenTheFile
			.elseif eax == IDM_FILE_RECENT_DELLIST
				invoke  _DeleteFileKey
				invoke  _DeleteMenu
			.elseif eax == IDM_FILE_EXIT
				invoke  SendMessage,hWnd,WM_CLOSE,0,0
			.elseif eax == IDM_EDIT_UNDO
				invoke	SendMessage,hEdit,EM_UNDO,0,0
			.elseif	eax ==	IDM_EDIT_REDO
				invoke	SendMessage,hEdit,EM_REDO,0,0
			.elseif eax == IDM_EDIT_CUT
				invoke	SendMessage,hEdit,WM_CUT,0,0
			.elseif eax == IDM_EDIT_COPY
				invoke	SendMessage,hEdit,WM_COPY,0,0
			.elseif eax == IDM_EDIT_PASTE
				invoke	SendMessage,hEdit,WM_PASTE,0,0
			.elseif eax == IDM_EDIT_DEL
				invoke SendMessage,hEdit,EM_REPLACESEL,TRUE,NULL
			.elseif eax == IDM_EDIT_CHANG_CHANG
				mov bToUpper,TRUE
				mov bToLower,TRUE
				invoke _LetterChange
			.elseif eax == IDM_EDIT_CHANG_UPPER
				mov bToUpper,TRUE
				mov bToLower,FALSE
				invoke _LetterChange
			.elseif eax == IDM_EDIT_CHANG_LOWER
				mov bToUpper,FALSE
				mov bToLower,TRUE
				invoke _LetterChange
			.elseif eax >= IDM_EDIT_INSERT_DATE1 && eax <= IDM_EDIT_INSERT_DATE7
				invoke	GetMenuString,hMenu,eax,addr szBuffer1,\
					sizeof szBuffer1,MF_BYCOMMAND
				invoke SendMessage,hEdit,EM_REPLACESEL,TRUE,addr szBuffer1
			.elseif eax == IDM_EDIT_SELECTALL
				mov	@stRange.cpMin,0
				mov	@stRange.cpMax,-1
				invoke	SendMessage,hEdit,EM_EXSETSEL,0,addr @stRange
			.elseif eax == IDM_SEARCH_FIND
				and	stFind.Flags,not FR_DIALOGTERM
				invoke	FindText,addr stFind
				.if	eax
					mov	hFindDialog,eax
				.endif
			.elseif	eax ==	IDM_SEARCH_PREV
				and	stFind.Flags,not FR_DOWN
				invoke	_FindText
			.elseif eax == IDM_SEARCH_NEXT
				or	stFind.Flags,FR_DOWN
				invoke	_FindText
			.elseif eax == IDM_SEARCH_REPLACE
				and	stFind.Flags,not FR_DIALOGTERM
				invoke	ReplaceText,addr stFind
				.if	eax
					mov	hFindDialog,eax
				.endif
			.elseif eax == IDM_SEARCH_GOTO
				invoke CreateDialogParam,hInstance,DLG_GOTO,\
					hWnd,addr _ProcGotoDlg,NULL
				mov hDlgGoto,eax
			.elseif eax == IDM_CONFIG_FONT
				invoke _ChooseFont
			.elseif eax == IDM_CONFIG_BKCOLOR
				invoke _ChooseColor
			.elseif eax == IDM_CONFIG_TOOL
				xor	bTool,TRUE
				invoke	_ResizeWindow
			.elseif eax == IDM_CONFIG_STATUS
				xor	bStatus,TRUE
				invoke	_ResizeWindow
			.elseif eax == IDM_CONFIG_BAR
				xor bShowBar,TRUE
            			invoke SendMessage,hEdit,EM_SETOPTIONS,ECOOP_XOR,ECO_SELECTIONBAR
			.elseif eax == IDM_CONFIG_WRAP
				xor bWrap,TRUE
				invoke _WordWrap
			.elseif eax == IDM_CONFIG_OPTION

				invoke DialogBoxParam,hInstance,DLG_OPTION,\
					hWnd,addr _ProcOptionDlg,NULL
			.elseif eax == IDM_HELP_HELP
				invoke DialogBoxParam,hInstance,DLG_SOFT,\
					hWnd,addr _ProcSoftDlg,NULL
				mov hDlgSoft,eax
			.elseif eax == IDM_HELP_SOFT
				invoke DialogBoxParam,hInstance,DLG_SOFT,\
					hWnd,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -