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

📄 stringedit.asm

📁 汇编资源编辑器
💻 ASM
字号:

;StringEdit.dlg
IDD_DLGSTRING							equ 1200
IDC_GRDSTR								equ 1001
IDC_BTNSTRADD							equ 1002
IDC_BTNSTRDEL							equ 1003

.code

ExportStringNames proc uses esi edi,hMem:DWORD

	invoke GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,64*1024
	mov		edi,eax
	invoke GlobalLock,edi
	push	edi
	mov		esi,hMem
	.while byte ptr [esi].STRINGMEM.szname || [esi].STRINGMEM.value
		.if byte ptr [esi].STRINGMEM.szname && [esi].STRINGMEM.value
			invoke SaveStr,edi,offset szDEFINE
			add		edi,eax
			mov		al,' '
			stosb
			invoke SaveStr,edi,addr [esi].STRINGMEM.szname
			add		edi,eax
			mov		al,' '
			stosb
			invoke SaveVal,[esi].STRINGMEM.value,FALSE
			mov		al,0Dh
			stosb
			mov		al,0Ah
			stosb
		.endif
		add		esi,sizeof STRINGMEM
	.endw
	mov		byte ptr [edi],0
	pop		eax
	ret

ExportStringNames endp

ExportString proc uses esi edi,hMem:DWORD

	invoke GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,64*1024
	mov		edi,eax
	invoke GlobalLock,edi
	push	edi
	mov		esi,hMem
	invoke SaveStr,edi,offset szSTRINGTABLE
	add		edi,eax
	mov		al,' '
	stosb
	invoke SaveStr,edi,offset szDISCARDABLE
	add		edi,eax
	mov		al,0Dh
	stosb
	mov		al,0Ah
	stosb
	invoke SaveStr,edi,offset szBEGIN
	add		edi,eax
	mov		al,0Dh
	stosb
	mov		al,0Ah
	stosb
	.while byte ptr [esi].STRINGMEM.szname || [esi].STRINGMEM.value
		mov		al,' '
		stosb
		stosb
		.if byte ptr [esi].STRINGMEM.szname
			invoke SaveStr,edi,addr [esi].STRINGMEM.szname
			add		edi,eax
		.else
			invoke SaveVal,[esi].STRINGMEM.value,FALSE
		.endif
		mov		al,' '
		stosb
		mov		al,'"'
		stosb
		xor		ecx,ecx
		.while byte ptr [esi+ecx].STRINGMEM.szstring
			mov		al,[esi+ecx].STRINGMEM.szstring
			mov		[edi],al
			inc		ecx
			inc		edi
		.endw
		mov		al,'"'
		stosb
		mov		al,0Dh
		stosb
		mov		al,0Ah
		stosb
		add		esi,sizeof STRINGMEM
	.endw
	invoke SaveStr,edi,offset szEND
	add		edi,eax
	mov		al,0Dh
	stosb
	mov		al,0Ah
	stosb
	mov		byte ptr [edi],0
	pop		eax
	ret

ExportString endp

SaveStringEdit proc uses esi edi,hWin:HWND
	LOCAL	hGrd:HWND
	LOCAL	nRows:DWORD
	LOCAL	buffer[MAX_PATH]:BYTE

	invoke GetDlgItem,hWin,IDC_GRDSTR
	mov		hGrd,eax
	invoke SendMessage,hGrd,GM_GETROWCOUNT,0,0
	mov		nRows,eax
	invoke GetWindowLong,hWin,GWL_USERDATA
	.if !eax
		invoke SendMessage,hPrj,PRO_ADDITEM,TPE_STRING,FALSE
	.endif
	mov		edi,[eax].PROJECT.hmem
	xor		esi,esi
	.while esi<nRows
		;Name
		mov		ecx,esi
		shl		ecx,16
		invoke SendMessage,hGrd,GM_GETCELLDATA,ecx,addr buffer
		invoke lstrcpy,addr [edi].STRINGMEM.szname,addr buffer
		;ID
		mov		ecx,esi
		shl		ecx,16
		add		ecx,1
		invoke SendMessage,hGrd,GM_GETCELLDATA,ecx,addr buffer
		mov		eax,dword ptr buffer
		mov		[edi].STRINGMEM.value,eax
		;String
		mov		ecx,esi
		shl		ecx,16
		add		ecx,2
		invoke SendMessage,hGrd,GM_GETCELLDATA,ecx,addr buffer
		invoke lstrcpy,addr [edi].STRINGMEM.szstring,addr buffer
		.if [edi].STRINGMEM.szname || [edi].STRINGMEM.value
			add		edi,sizeof STRINGMEM
		.endif
		inc		esi
	.endw
	xor		eax,eax
	mov		[edi].STRINGMEM.szname,al
	mov		[edi].STRINGMEM.value,eax
	mov		[edi].STRINGMEM.szstring,al
	ret

SaveStringEdit endp

StringEditProc proc uses esi,hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
	LOCAL	hGrd:HWND
	LOCAL	col:COLUMN
	LOCAL	row[3]:DWORD

	mov		eax,uMsg
	.if eax==WM_INITDIALOG
		invoke GetDlgItem,hWin,IDC_GRDSTR
		mov		hGrd,eax
		invoke SendMessage,hWin,WM_GETFONT,0,0
		invoke SendMessage,hGrd,WM_SETFONT,eax,FALSE
		;Name
		mov		col.colwt,100
		mov		col.lpszhdrtext,offset szHdrName
		mov		col.halign,GA_ALIGN_LEFT
		mov		col.calign,GA_ALIGN_LEFT
		mov		col.ctype,TYPE_EDITTEXT
		mov		col.ctextmax,31
		mov		col.lpszformat,0
		mov		col.himl,0
		mov		col.hdrflag,0
		invoke SendMessage,hGrd,GM_ADDCOL,0,addr col
		;ID
		mov		col.colwt,40
		mov		col.lpszhdrtext,offset szHdrID
		mov		col.halign,GA_ALIGN_RIGHT
		mov		col.calign,GA_ALIGN_RIGHT
		mov		col.ctype,TYPE_EDITLONG
		mov		col.ctextmax,5
		mov		col.lpszformat,0
		mov		col.himl,0
		mov		col.hdrflag,0
		invoke SendMessage,hGrd,GM_ADDCOL,0,addr col
		;String
		mov		col.colwt,230
		mov		col.lpszhdrtext,offset szHdrString
		mov		col.halign,GA_ALIGN_LEFT
		mov		col.calign,GA_ALIGN_LEFT
		mov		col.ctype,TYPE_EDITTEXT
		mov		col.ctextmax,127
		mov		col.lpszformat,0
		mov		col.himl,0
		mov		col.hdrflag,0
		invoke SendMessage,hGrd,GM_ADDCOL,0,addr col
		mov		esi,lParam
		.if ![esi].PROJECT.hmem
			xor		esi,esi
		.endif
		invoke SetWindowLong,hWin,GWL_USERDATA,esi
		.if esi
			mov		esi,[esi].PROJECT.hmem
			.while [esi].STRINGMEM.szname || [esi].STRINGMEM.value
				lea		eax,[esi].STRINGMEM.szname
				mov		row[0],eax
				mov		eax,[esi].STRINGMEM.value
				mov		row[4],eax
				lea		eax,[esi].STRINGMEM.szstring
				mov		row[8],eax
				invoke SendMessage,hGrd,GM_ADDROW,0,addr row
				add		esi,sizeof STRINGMEM 
			.endw
			invoke SendMessage,hGrd,GM_SETCURSEL,0,0
		.endif
	.elseif eax==WM_COMMAND
		invoke GetDlgItem,hWin,IDC_GRDSTR
		mov		hGrd,eax
		mov		edx,wParam
		movzx	eax,dx
		shr		edx,16
		.if edx==BN_CLICKED
			.if eax==IDOK
				invoke SaveStringEdit,hWin
				invoke SendMessage,hPrj,PRO_SETMODIFY,TRUE,0
				invoke SendMessage,hWin,WM_CLOSE,TRUE,NULL
			.elseif eax==IDCANCEL
				invoke SendMessage,hWin,WM_CLOSE,FALSE,NULL
			.elseif eax==IDC_BTNSTRADD
				invoke SendMessage,hGrd,GM_ADDROW,0,NULL
				invoke SendMessage,hGrd,GM_SETCURSEL,0,eax
				invoke SetFocus,hGrd
				xor		eax,eax
				jmp		Ex
			.elseif eax==IDC_BTNSTRDEL
				invoke SendMessage,hGrd,GM_GETCURROW,0,0
				push	eax
				invoke SendMessage,hGrd,GM_DELROW,eax,0
				pop		eax
				invoke SendMessage,hGrd,GM_SETCURSEL,0,eax
				invoke SetFocus,hGrd
				xor		eax,eax
				jmp		Ex
			.endif
		.endif
	.elseif eax==WM_NOTIFY
		invoke GetDlgItem,hWin,IDC_GRDSTR
		mov		hGrd,eax
		mov		esi,lParam
		mov		eax,[esi].NMHDR.hwndFrom
		.if eax==hGrd
			mov		eax,[esi].NMHDR.code
			.if eax==GN_HEADERCLICK
				;Sort the grid by column, invert sorting order
				invoke SendMessage,hGrd,GM_COLUMNSORT,[esi].GRIDNOTIFY.col,SORT_INVERT
			.endif
		.endif
	.elseif eax==WM_CLOSE
		invoke EndDialog,hWin,wParam
	.else
		mov		eax,FALSE
		ret
	.endif
	mov		eax,TRUE
  Ex:
	ret

StringEditProc endp

⌨️ 快捷键说明

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