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

📄 notepro.asm

📁 一个简单的记事本
💻 ASM
📖 第 1 页 / 共 5 页
字号:
_SetFont	proc	_lpszFont,_dwFontSize,_dwColor
		local	@stCf		:CHARFORMAT

		invoke	RtlZeroMemory,addr @stCf,sizeof @stCf
		mov	@stCf.cbSize,sizeof @stCf
		mov	@stCf.dwMask,CFM_SIZE or CFM_FACE or CFM_COLOR or CFM_BOLD
		push	_dwFontSize
		pop	@stCf.yHeight
		push	_dwColor
		pop	@stCf.crTextColor
		mov	@stCf.dwEffects,0
		invoke	lstrcpy,addr @stCf.szFaceName,_lpszFont
		invoke	SendMessage,hEdit,EM_SETTEXTMODE,1,0
		invoke	SendMessage,hEdit,EM_SETCHARFORMAT,0,addr @stCf
		ret
_SetFont	endp
;>>>>>>>>>>>>>>>>>>>>>设置标题栏>及部分工具栏>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_SetCaption	proc
		local	@szBuffer[1024]:byte

		.if	szFileName
			.if bFullPath
				mov	ebx,offset szFileName
			.else
				invoke _GetFileTitle
				mov	ebx,offset szFileTitle
			.endif
		.else
			mov	ebx,offset szNoName
		.endif
		invoke	SendMessage,hEdit,EM_GETMODIFY,0,0
		.if 	 eax
			invoke	wsprintf,addr @szBuffer,addr szTitleFormat2,ebx,addr szCharStar
			mov	bHasModifyFlag,TRUE
		.else
			invoke	wsprintf,addr @szBuffer,addr szTitleFormat1,ebx
			mov	bHasModifyFlag,FALSE
		.endif
		invoke	SetWindowText,hWinMain,addr @szBuffer

		ret
_SetCaption	endp

;>>>>>>>>>>>>>>设置工具栏状态>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_SetToolStatus	proc
	local	@szBuffer[256]	:byte
	local	@stRange		:CHARRANGE

		.if hFile
			invoke GetFileAttributes,addr szFileName
			.if eax & FILE_ATTRIBUTE_READONLY 
			  	.if !bReadOnlyFlag
					invoke SendMessage,hEdit,EM_SETOPTIONS,ECOOP_XOR,ECO_READONLY
			  	.endif
				mov	bReadOnlyFlag,TRUE
			.else
			  	.if bReadOnlyFlag
					invoke SendMessage,hEdit,EM_SETOPTIONS,ECOOP_XOR,ECO_READONLY
			  	.endif
				mov	bReadOnlyFlag,FALSE
			.endif
		.endif
		invoke	SendMessage,hEdit,EM_GETMODIFY,0,0
		.if	bHasModifyFlag && !bReadOnlyFlag
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_FILE_SAVE,TRUE
		.else
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_FILE_SAVE,FALSE
		.endif
		invoke	SendMessage,hEdit,EM_EXGETSEL,0,addr @stRange
		mov	eax,@stRange.cpMin
		.if	eax ==	@stRange.cpMax
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_EDIT_COPY,FALSE
		.else
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_EDIT_COPY,TRUE
		.endif
		mov	eax,@stRange.cpMin
		.if	eax ==	@stRange.cpMax || bReadOnlyFlag
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_EDIT_CUT,FALSE
		.else
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_EDIT_CUT,TRUE
		.endif
		invoke	IsClipboardFormatAvailable,CF_TEXT
		.if	eax && !bReadOnlyFlag
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_EDIT_PASTE,TRUE
		.else
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_EDIT_PASTE,FALSE
		.endif
		invoke	SendMessage,hEdit,EM_CANREDO,0,0
		.if	eax && !bReadOnlyFlag
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_EDIT_REDO,TRUE
		.else
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_EDIT_REDO,FALSE
		.endif
		invoke	SendMessage,hEdit,EM_CANUNDO,0,0
		.if	eax && !bReadOnlyFlag
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_EDIT_UNDO,TRUE
		.else
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_EDIT_UNDO,FALSE
		.endif
		.if bReadOnlyFlag
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_SEARCH_REPLACE,FALSE
		.else
			invoke	SendMessage,hToolBar,TB_ENABLEBUTTON,IDM_SEARCH_REPLACE,TRUE
		.endif
	ret
_SetToolStatus	endp
;>>>>>>>>>>>>>>>>设置状态栏状态>>>>>>>>>>>>>>>>>>>>>>>>
_SetStatusStatus	proc
	local	@szBuffer[256]	:byte
	local	@stRange		:CHARRANGE

		invoke	SendMessage,hStatus,SB_SETTEXT,0 or SBT_NOBORDERS,addr szReady
		invoke	SendMessage,hEdit,EM_EXGETSEL,0,addr @stRange
		invoke	SendMessage,hEdit,EM_EXLINEFROMCHAR,0,-1
		inc eax
		invoke	wsprintf,addr @szBuffer,addr szLineFormat,eax
		invoke	SendMessage,hStatus,SB_SETTEXT,1,addr @szBuffer

		invoke	SendMessage,hEdit,EM_GETLINECOUNT,0,0
		invoke	wsprintf,addr @szBuffer,addr szLinesFormat,eax
		invoke	SendMessage,hStatus,SB_SETTEXT,2,addr @szBuffer

		invoke	GetWindowTextLength,hEdit
		invoke	wsprintf,addr @szBuffer,addr szCharsFormat,eax
		invoke	SendMessage,hStatus,SB_SETTEXT,3,addr @szBuffer
	
		.if bReadOnlyFlag
			invoke	SendMessage,hStatus,SB_SETTEXT,4,addr szRMode
		.else
			invoke	SendMessage,hStatus,SB_SETTEXT,4,addr szRWMode
		.endif
		;***************捕获各控制键******************
		.if bInsertFlag
			invoke	SendMessage,hStatus,SB_SETTEXT,5,addr szInsert
		.else
			invoke	SendMessage,hStatus,SB_SETTEXT,5,addr szUnInsert
		.endif
		invoke GetKeyState,VK_CAPITAL
		.if eax == -127 || eax == 1
			invoke	SendMessage,hStatus,SB_SETTEXT,6,addr szCapsLock
		.elseif eax == -128 || eax == 0
			invoke	SendMessage,hStatus,SB_SETTEXT,6,addr szCapsUnLock
		.endif
		invoke GetKeyState,VK_NUMLOCK
		.if eax == -127 || eax == 1
			invoke	SendMessage,hStatus,SB_SETTEXT,7,addr szNumLock
		.elseif eax == -128 || eax == 0
			invoke	SendMessage,hStatus,SB_SETTEXT,7,addr szNumUnLock
		.endif
	ret
_SetStatusStatus	endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>菜单设置>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_SetMenuStatus	proc
	local	@stRange		:CHARRANGE

		.if hFile
			invoke GetFileAttributes,addr szFileName
			.if eax & FILE_ATTRIBUTE_READONLY
				mov	bReadOnlyFlag,TRUE
			.else
				mov	bReadOnlyFlag,FALSE
			.endif
		.endif
		invoke	SendMessage,hEdit,EM_EXGETSEL,0,addr @stRange
		mov	eax,@stRange.cpMin
		.if	eax ==	@stRange.cpMax
			invoke	EnableMenuItem,hMenu,IDM_EDIT_COPY,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_CUT,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_DEL,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_CHANG_CHANG,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_CHANG_UPPER,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_CHANG_LOWER,MF_GRAYED
		.else
			invoke	EnableMenuItem,hMenu,IDM_EDIT_COPY,MF_ENABLED
			.if !bReadOnlyFlag
				invoke	EnableMenuItem,hMenu,IDM_EDIT_CUT,MF_ENABLED
				invoke	EnableMenuItem,hMenu,IDM_EDIT_DEL,MF_ENABLED
				invoke	EnableMenuItem,hMenu,IDM_EDIT_CHANG_CHANG,MF_ENABLED
				invoke	EnableMenuItem,hMenu,IDM_EDIT_CHANG_UPPER,MF_ENABLED
				invoke	EnableMenuItem,hMenu,IDM_EDIT_CHANG_LOWER,MF_ENABLED
			.endif
		.endif
		;************************************************************
		invoke	IsClipboardFormatAvailable,CF_TEXT
		.if	eax && !bReadOnlyFlag
			invoke	EnableMenuItem,hMenu,IDM_EDIT_PASTE,MF_ENABLED
		.else
			invoke	EnableMenuItem,hMenu,IDM_EDIT_PASTE,MF_GRAYED
		.endif
		;********************************************************************
		invoke	SendMessage,hEdit,EM_CANREDO,0,0
		.if	eax && !bReadOnlyFlag
			invoke	EnableMenuItem,hMenu,IDM_EDIT_REDO,MF_ENABLED
		.else
			invoke	EnableMenuItem,hMenu,IDM_EDIT_REDO,MF_GRAYED
		.endif
		;********************************************************************
		invoke	SendMessage,hEdit,EM_CANUNDO,0,0
		.if	eax && !bReadOnlyFlag
			invoke	EnableMenuItem,hMenu,IDM_EDIT_UNDO,MF_ENABLED
		.else
			invoke	EnableMenuItem,hMenu,IDM_EDIT_UNDO,MF_GRAYED
		.endif
		;*********************************************************************
		invoke	GetWindowTextLength,hEdit
		.if	eax
			invoke	EnableMenuItem,hMenu,IDM_EDIT_SELECTALL,MF_ENABLED
		.else
			invoke	EnableMenuItem,hMenu,IDM_EDIT_SELECTALL,MF_GRAYED
		.endif
		;********************************************************************
		invoke	SendMessage,hEdit,EM_GETMODIFY,0,0
		.if	eax
			invoke	EnableMenuItem,hMenu,IDM_FILE_SAVE,MF_ENABLED
		.else
			invoke	EnableMenuItem,hMenu,IDM_FILE_SAVE,MF_GRAYED
		.endif
		;********************************************************************
		.if	szFindText
			invoke	EnableMenuItem,hMenu,IDM_SEARCH_NEXT,MF_ENABLED
			invoke	EnableMenuItem,hMenu,IDM_SEARCH_PREV,MF_ENABLED
		.else
			invoke	EnableMenuItem,hMenu,IDM_SEARCH_NEXT,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_SEARCH_PREV,MF_GRAYED
		.endif
		;********************************************************************
		.if	!bReadOnlyFlag
			invoke	EnableMenuItem,hMenu,IDM_SEARCH_REPLACE,MF_ENABLED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE1,MF_ENABLED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE1+1,MF_ENABLED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE1+2,MF_ENABLED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE1+3,MF_ENABLED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE1+4,MF_ENABLED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE1+5,MF_ENABLED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE7,MF_ENABLED
		.else
			invoke	EnableMenuItem,hMenu,IDM_SEARCH_REPLACE,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE1,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE1+1,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE1+2,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE1+3,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE1+4,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE1+5,MF_GRAYED
			invoke	EnableMenuItem,hMenu,IDM_EDIT_INSERT_DATE7,MF_GRAYED
		.endif
		;********************************************************************
		.if	bStatus
			invoke	CheckMenuItem,hMenu,IDM_CONFIG_STATUS,MF_CHECKED
		.else
			invoke	CheckMenuItem,hMenu,IDM_CONFIG_STATUS,MF_UNCHECKED
		.endif
		;********************************************************************
		.if	bTool
			invoke	CheckMenuItem,hMenu,IDM_CONFIG_TOOL,MF_CHECKED
		.else
			invoke	CheckMenuItem,hMenu,IDM_CONFIG_TOOL,MF_UNCHECKED
		.endif
		;***************************************************************
		.if	bShowBar
			invoke	CheckMenuItem,hMenu,IDM_CONFIG_BAR,MF_CHECKED
		.else
			invoke	CheckMenuItem,hMenu,IDM_CONFIG_BAR,MF_UNCHECKED
		.endif
		;***************************************************************
		.if	bWrap
			invoke	CheckMenuItem,hMenu,IDM_CONFIG_WRAP,MF_CHECKED
		.else
			invoke	CheckMenuItem,hMenu,IDM_CONFIG_WRAP,MF_UNCHECKED
		.endif
	ret
_SetMenuStatus	endp
;>>>>>>>>>>>>>>>>>>>>>>>>页面设置对话框>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_PageSetup	proc
		local	@stPS:PAGESETUPDLG

		invoke	RtlZeroMemory,addr @stPS,sizeof @stPS
		mov	@stPS.lStructSize,sizeof @stPS
		mov	@stPS.flags,PSD_DISABLEMARGINS or PSD_DISABLEORIENTATION or PSD_DISABLEPAGEPAINTING
		push	hWinMain
		pop	@stPS.hwndOwner
		invoke	PageSetupDlg,addr @stPS
		ret

_PageSetup	endp
;>>>>>>>>>>>>>>>>>>>>>>取得打印机句柄>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_GetPrinterDC	proc
		local @dwNeeded:DWORD
		local @dwReturned:DWORD
		local @PInfo:PRINTER_INFO_4


		ret
_GetPrinterDC	endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_PrintText	proc

		ret
_PrintText	endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_FindText	proc
		local	@stFindText:FINDTEXTEX

		invoke	SendMessage,hEdit,EM_EXGETSEL,0,addr @stFindText.chrg
		.if	stFind.Flags & FR_DOWN
			push	@stFindText.chrg.cpMax
			pop	@stFindText.chrg.cpMin
		.endif
		mov	@stFindText.chrg.cpMax,-1
		mov	@stFindText.lpstrText,offset szFindText
		mov	ecx,stFind.Flags
		and	ecx,FR_MATCHCASE or FR_DOWN or FR_WHOLEWORD
		invoke	SendMessage,hEdit,EM_FINDTEXTEX,ecx,addr @stFindText
		.if	eax ==	-1
			mov	ecx,hWinMain
			.if	hFindDialog
				mov	ecx,hFindDialog
			.endif
			.if bReplaceAllFlag
				invoke	MessageBox,ecx,addr szReplaceInfo,NULL,\
					MB_OK or MB_ICONINFORMATION
				mov eax,-1				
			.elseif
				invoke	MessageBox,ecx,addr szNotFound,NULL,\
					MB_OK or MB_ICONINFORMATION
			.endif
			ret
		.endif
		invoke	SendMessage,hEdit,EM_EXSETSEL,0,addr @stFindText.chrgText
		invoke	SendMessage,hEdit,EM_SCROLLCARET,NULL,NULL
		ret

_FindText	endp
;*********************重新排列各控件**********************
_ResizeWindow	proc

		.if	bTool
			invoke	ShowWindow,hToolBar,SW_SHOW		
        		invoke SendMessage,hToolBar,TB_AUTOSIZE,0,0
		.elseif
			invoke	ShowWindow,hToolBar,SW_HIDE
		.endif
		.if	bStatus
			invoke	ShowWindow,hStatus,SW_SHOW
			invoke MoveWindow,hStatus,0,0,0,0,TRUE
			invoke _CreateTBParts
		.elseif
			invoke	ShowWindow,hStatus,SW_HIDE
		.endif
		invoke _EditSize
		ret
_ResizeWindow	endp
;>>>>>>>>>>>>>>>>>>>>>>>>>退出系统>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_Quit		proc
		invoke	_CheckModify
		.if	eax
			.if bSave
				invoke _WriteConfigFile
			.endif
			.if bPosition
				invoke _SaveWinPosition
			.endif
			invoke	DestroyWindow,hWinMain
			invoke	PostQuitMessage,NULL
			.if	hFile
				invoke	CloseHandle,hFile
			.endif
		.endif
		ret
_Quit		endp
;>>>>>>>>>>>>>>>>>>>>>>SPLASH的消息处理函数>>>>>>>>>>>>
_SplashProc proc hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
                   
    local @hDC 	:DWORD
    local @stRect 	:RECT
    local @stPs  	:PAINTSTRUCT
    local @hOldFont	:HFONT

    .if uMsg == WM_PAINT
        invoke BeginPaint,hWnd,addr @stPs
        mov 	 @hDC,eax
      	 invoke CreateFont,36,27,0,0,600,0,0,0,OEM_CHARSET,\ 
              OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,\ 
               DEFAULT_QUALITY,DEFAULT_PITCH or FF_SCRIPT,addr szFontFace 
        invoke SelectObject,@hDC,eax 
        mov    @hOldFont,eax 
        ;********************
        invoke GetClientRect,hWnd,addr @stRect
	 invoke SetBkMode,@hDC,TRANSPARENT
        invoke DrawText,@hDC,addr szClassName,-1,addr @stRect,\
                        DT_SINGLELINE or DT_VCENTER or DT_CENTER
	;*************************
        invoke SelectObject,@hDC,@hOldFont 
        invoke EndPaint,hWnd,addr @stPs
	 xor eax,eax
        ret
    .endif
    	invoke DefWindowProc,hWnd,uMsg,wParam,lParam
    ret
_SplashProc endp
;>>>>>>>>>>>>>>>>>>>>>>>选项对话框的消息处理函数>>>>>>>>>>>>
_ProcOptionDlg	proc	uses ebx edi esi,hWnd,uMsg,wParam,lParam

		mov eax,uMsg
		.if eax == WM_INITDIALOG
			mov 	eax,hWnd
			mov    hDlgOption,eax
			invoke _ShowTab1
			
		.elseif eax == WM_NOTIFY
			mov eax,lParam				
			mov eax, (NMHDR PTR [eax]).code
			.if eax == TCN_SELCHANGE
				INVOKE SendMessage,hTab1,TCM_GETCURSEL,0,0												; Ok which one is BEING chosen right now?
				MOV WhichTabChosen,EAX

⌨️ 快捷键说明

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