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

📄 hismenu.asm

📁 一个十六进制编辑器源代码,cool!
💻 ASM
字号:
_HisMenuAdd proto:DWORD 
_HisMenuLoad proto
_HisMenuDeleteAll proto
; hMenu 是全局菜单的句柄
.data
	szHisFile db 'Recent Files',0
	szHisCount db 'Count',0
	szKeyFile db 'File%u',0
	MAX_HISFILE equ 16 ;最大8个常用文件
	ID1=0;主菜单的第0个菜单(一般来讲,是“文件")
	ID2=2;文件菜单下的子菜单(一般来讲,第0个是新建,第1个是打开)
	ID_FIRSTHISMENU equ 60000
	ID_MENU_CLEARHIS equ ID_FIRSTHISMENU-1
	;在文件菜单中建立一个叫”重新打开"的弹出菜单,它也带一个子菜单,名为[清除],ID为59999
.data?
	hHisMenu dd ?
.code
;---------------------------------------
_HisMenuLoad proc 
;从INI文件中读取菜单项
local @szBuf[MAX_PATH]:BYTE ,nCount,@id,@index
local @szKey[10]:BYTE ,@hMenu
	invoke GetSubMenu,hMenu,0
	invoke GetSubMenu,eax,2
	mov @hMenu,eax
	invoke _IniGetInt,addr szHisFile,addr szHisCount
	.if eax==0
		invoke EnableMenuItem,hMenu,ID_MENU_CLEARHIS,MF_GRAYED 
		ret
	.endif
	pushad
	mov edi,eax
	mov esi,1
	mov @id,ID_FIRSTHISMENU
	.while esi<=edi
		invoke wsprintf,addr @szKey,addr szKeyFile,esi
		invoke _IniGetStr,addr szHisFile,addr @szKey	
		invoke AppendMenu,@hMenu,MF_STRING ,@id,lpIniBuf
		inc esi
		inc @id
	.endw
	invoke EnableMenuItem,hMenu,ID_MENU_CLEARHIS,MF_ENABLED
	popad
	ret
_HisMenuLoad endp
;--------------------------------------
_HisMenuAdd proc lpszFile
local @szBuf[MAX_PATH]:BYTE
local @szKey[10]:BYTE ,nCount
	pushad
	invoke _IniGetInt,addr szHisFile,addr szHisCount
	push eax
	mov nCount,eax
	mov esi,ID_FIRSTHISMENU
	mov edi,-1
	;删除已有的菜单
	.while nCount
		invoke DeleteMenu,hMenu,esi,MF_BYCOMMAND
		invoke wsprintf,addr @szKey,addr szKeyFile ,nCount
		invoke _IniGetStr,addr szHisFile,addr @szKey
		invoke lstrcmpi,lpszFile,lpIniBuf
		.if eax==0 && edi==-1
			;要添加的记录已存在
			mov edi,nCount
		.endif
		inc esi
		dec nCount
	.endw
	pop esi
	.if edi!=-1
		mov esi,edi
	.else
		inc esi		
		.if esi<=MAX_HISFILE
			invoke _IniSetInt,addr  szHisFile,addr szHisCount,esi
		.endif
	.endif
	;向下移动
	.while esi>1
		mov edi,esi
		dec edi
		invoke wsprintf,addr @szKey,addr szKeyFile,edi
		invoke _IniGetStr,addr szHisFile,addr @szKey	
		invoke wsprintf,addr @szKey,addr szKeyFile,esi
		invoke _IniSetStr,addr szHisFile,addr @szKey,lpIniBuf
		dec esi
	.endw
	invoke _IniSetStr,addr szHisFile,ctext("File1"),lpszFile
	;重新加载
	invoke _IniSetFileName,addr szIniFile,0
	call _HisMenuLoad
	popad
	ret
_HisMenuAdd endp
;---------------------------------------------
_HisMenuDeleteAll proc uses esi
		push esi
		invoke _IniSetFileName,addr szIniFile,0
		invoke _IniDelSection,addr szHisFile
		mov esi,ID_FIRSTHISMENU
		.while eax
			invoke DeleteMenu,hMenu,esi,MF_BYCOMMAND
			inc esi
		.endw
		invoke EnableMenuItem,hMenu,ID_MENU_CLEARHIS,MF_GRAYED 
		pop esi
	ret
_HisMenuDeleteAll endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;		.elseif ax>=ID_FIRSTHISMENU;历史菜单(最新文件)
;			movzx ebx,ax
;			invoke GetMenuString,hMenu,ebx,addr @szBuf,255,MF_BYCOMMAND 
;			call _GetModify
;			.if eax!=IDCANCEL 
;				invoke  _OpenFile,addr @szBuf
;			.endif
;		.elseif ax==ID_MENU_CLEARHIS;清除历史菜单
;			invoke _HisMenuDeleteAll
;		.else

⌨️ 快捷键说明

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