?? nameedit.asm
字號:
;StringEdit.dlg
IDD_DLGNAMES equ 1400
IDC_GRDNME equ 1001
IDC_BTNNMEADD equ 1002
IDC_BTNNMEDEL equ 1003
IDC_BTNNMEEXPORT equ 1004
.const
szExportAs db 'Export Names As',0
.data?
nExportType dd ?
szExportFileName db MAX_PATH dup(?)
.code
ExportNamesNames 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].NAMEMEM.szname || [esi].NAMEMEM.value
.if ![esi].NAMEMEM.delete
invoke SaveStr,edi,offset szDEFINE
add edi,eax
mov al,' '
stosb
invoke SaveStr,edi,addr [esi].NAMEMEM.szname
add edi,eax
mov al,' '
stosb
invoke SaveVal,[esi].NAMEMEM.value,FALSE
mov al,0Dh
stosb
mov al,0Ah
stosb
.endif
add esi,sizeof NAMEMEM
.endw
mov byte ptr [edi],0
pop eax
ret
ExportNamesNames endp
UpdateNames proc uses ebx esi,hWin:HWND
LOCAL hGrd:HWND
LOCAL lpProMem:DWORD
LOCAL nRows:DWORD
LOCAL buffer[MAX_PATH]:BYTE
LOCAL val:DWORD
LOCAL fChanged:DWORD
invoke GetWindowLong,hPrj,0
mov lpProMem,eax
invoke GetDlgItem,hWin,IDC_GRDNME
mov hGrd,eax
invoke SendMessage,hGrd,GM_GETROWCOUNT,0,0
mov nRows,eax
xor ebx,ebx
.while ebx<nRows
;Name
mov ecx,ebx
shl ecx,16
invoke SendMessage,hGrd,GM_GETCELLDATA,ecx,addr val
mov ecx,ebx
shl ecx,16
add ecx,3
invoke SendMessage,hGrd,GM_GETCELLDATA,ecx,addr buffer
.if val
invoke lstrcmp,val,addr buffer
.if eax
invoke lstrcpy,val,addr buffer
mov fChanged,TRUE
.endif
;ID
mov ecx,ebx
shl ecx,16
add ecx,1
invoke SendMessage,hGrd,GM_GETCELLDATA,ecx,addr val
mov ecx,ebx
shl ecx,16
add ecx,4
invoke SendMessage,hGrd,GM_GETCELLDATA,ecx,addr buffer
mov edx,val
mov eax,dword ptr buffer
.if eax!=[edx]
mov [edx],eax
mov fChanged,TRUE
.endif
.else
.if buffer
mov ecx,ebx
shl ecx,16
add ecx,4
invoke SendMessage,hGrd,GM_GETCELLDATA,ecx,addr val
invoke ResEdBinToDec,val,addr buffer[64]
invoke AddName,lpProMem,addr buffer,addr buffer[64]
mov fChanged,TRUE
.endif
.endif
inc ebx
.endw
.if fChanged
invoke GetWindowLong,hPrj,0
mov esi,eax
.while [esi].PROJECT.hmem
mov eax,[esi].PROJECT.ntype
.if eax==TPE_DIALOG
mov ebx,[esi].PROJECT.hmem
lea ebx,[ebx+sizeof DLGHEAD]
mov ecx,[ebx].DIALOG.id
lea edx,[ebx].DIALOG.idname
call UpdateProject
.elseif eax==TPE_MENU
mov ebx,[esi].PROJECT.hmem
mov ecx,[ebx].MNUHEAD.menuid
lea edx,[ebx].MNUHEAD.menuname
call UpdateProject
.elseif eax==TPE_ACCEL
mov ebx,[esi].PROJECT.hmem
mov ecx,[ebx].ACCELMEM.value
lea edx,[ebx].ACCELMEM.szname
call UpdateProject
.endif
add esi,sizeof PROJECT
.endw
invoke SendMessage,hPrj,PRO_SETMODIFY,TRUE,0
invoke GetWindowLong,hPrp,0
invoke GetWindowLong,eax,GWL_USERDATA
.if eax
invoke PropertyList,eax
.endif
.endif
ret
UpdateProject:
.if byte ptr [edx]
invoke lstrcpy,addr buffer,edx
.else
invoke ResEdBinToDec,ecx,addr buffer
.endif
invoke SetProjectItemName,esi,addr buffer
retn
UpdateNames endp
SaveNamesToFile proc uses ebx esi edi,hWin:HWND
LOCAL hGrd:HWND
LOCAL nRows:DWORD
LOCAL buffer[MAX_PATH]:BYTE
LOCAL val:DWORD
LOCAL ofn:OPENFILENAME
LOCAL hFile:DWORD
mov eax,nExportType
shr eax,16
.if !eax
;Zero out the ofn struct
invoke RtlZeroMemory,addr ofn,sizeof ofn
mov ofn.lStructSize,sizeof ofn
push hWin
pop ofn.hwndOwner
push hInstance
pop ofn.hInstance
mov ofn.lpstrTitle,offset szExportAs
mov ofn.lpstrInitialDir,offset szProjectPath
mov ofn.lpstrFile,offset szExportFileName
mov ofn.nMaxFile,sizeof szExportFileName
mov ofn.lpstrDefExt,NULL
mov ofn.Flags,OFN_OVERWRITEPROMPT or OFN_HIDEREADONLY
;Show the Save dialog
invoke GetSaveFileName,addr ofn
.endif
.if eax
invoke GlobalAlloc,GMEM_FIXED or GMEM_ZEROINIT,64*1024
mov edi,eax
invoke GlobalLock,edi
push edi
invoke GetDlgItem,hWin,IDC_GRDNME
mov hGrd,eax
invoke SendMessage,hGrd,GM_GETROWCOUNT,0,0
mov nRows,eax
xor ebx,ebx
.while ebx<nRows
;Name
mov ecx,ebx
shl ecx,16
add ecx,3
invoke SendMessage,hGrd,GM_GETCELLDATA,ecx,addr buffer
.if buffer
;ID
mov ecx,ebx
shl ecx,16
add ecx,4
invoke SendMessage,hGrd,GM_GETCELLDATA,ecx,addr val
.if val
movzx eax,word ptr nExportType
.if eax==0
invoke SaveStr,edi,addr buffer
add edi,eax
.if eax<23
mov ecx,23
sub ecx,eax
mov al,' '
rep stosb
.endif
mov al,' '
stosb
mov eax,' uqe'
stosd
invoke SaveVal,val,FALSE
mov al,0Dh
stosb
mov al,0Ah
stosb
.elseif eax==1
invoke SaveStr,edi,offset szDEFINE
add edi,eax
mov al,' '
stosb
invoke SaveStr,edi,addr buffer
add edi,eax
.if eax<23
mov ecx,23
sub ecx,eax
mov al,' '
rep stosb
.endif
mov al,' '
stosb
invoke SaveVal,val,FALSE
mov al,0Dh
stosb
mov al,0Ah
stosb
.elseif eax==2
invoke SaveStr,edi,addr buffer
add edi,eax
.if eax<23
mov ecx,23
sub ecx,eax
mov al,' '
rep stosb
.endif
mov eax,' =: '
stosd
invoke SaveVal,val,FALSE
mov al,';'
stosb
mov al,0Dh
stosb
mov al,0Ah
stosb
.endif
.endif
.endif
inc ebx
.endw
mov byte ptr [edi],0
pop edi
mov eax,nExportType
shr eax,16
.if !eax
invoke CreateFile,offset szExportFileName,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL
.if eax!=INVALID_HANDLE_VALUE
mov hFile,eax
invoke lstrlen,edi
mov edx,eax
invoke WriteFile,hFile,edi,edx,addr buffer,NULL
invoke CloseHandle,hFile
.endif
.elseif eax==1
invoke lstrlen,edi
invoke ClipDataSet,edi,eax
.elseif eax==2
invoke SendMessage,hExportOut,WM_SETTEXT,0,edi
.endif
invoke GlobalUnlock,edi
invoke GlobalFree,edi
.endif
ret
SaveNamesToFile endp
NameEditProc proc uses ebx esi,hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL hGrd:HWND
LOCAL hMem:DWORD
LOCAL col:COLUMN
LOCAL row[5]:DWORD
LOCAL buffer[MAX_PATH]:BYTE
mov eax,uMsg
.if eax==WM_INITDIALOG
invoke GetDlgItem,hWin,IDC_GRDNME
mov hGrd,eax
invoke SendMessage,hWin,WM_GETFONT,0,0
invoke SendMessage,hGrd,WM_SETFONT,eax,FALSE
;lpName
mov col.colwt,0
mov col.lpszhdrtext,NULL
mov col.halign,GA_ALIGN_RIGHT
mov col.calign,GA_ALIGN_RIGHT
mov col.ctype,TYPE_EDITLONG
mov col.ctextmax,0
mov col.lpszformat,0
mov col.himl,0
mov col.hdrflag,0
invoke SendMessage,hGrd,GM_ADDCOL,0,addr col
;lpID
mov col.colwt,0
mov col.lpszhdrtext,NULL
mov col.halign,GA_ALIGN_RIGHT
mov col.calign,GA_ALIGN_RIGHT
mov col.ctype,TYPE_EDITLONG
mov col.ctextmax,0
mov col.lpszformat,0
mov col.himl,0
mov col.hdrflag,0
invoke SendMessage,hGrd,GM_ADDCOL,0,addr col
;Image
mov col.colwt,18
mov col.lpszhdrtext,NULL
mov col.halign,GA_ALIGN_RIGHT
mov col.calign,GA_ALIGN_RIGHT
mov col.ctype,TYPE_IMAGE
mov col.ctextmax,0
mov col.lpszformat,0
mov eax,hPrjIml
mov col.himl,eax
mov col.hdrflag,0
invoke SendMessage,hGrd,GM_ADDCOL,0,addr col
;Name
mov col.colwt,122
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
invoke GetWindowLong,hPrj,0
mov esi,eax
mov hMem,esi
.while [esi].PROJECT.hmem
.if [esi].PROJECT.ntype==TPE_NAME && ![esi].PROJECT.delete
mov ebx,[esi].PROJECT.hmem
;Image
mov row[8],0
.while [ebx].NAMEMEM.szname
.if ![ebx].NAMEMEM.delete
;lpName
lea eax,[ebx].NAMEMEM.szname
mov row[0],eax
mov row[12],eax
;lpID
lea eax,[ebx].NAMEMEM.value
mov row[4],eax
mov eax,[eax]
mov row[16],eax
invoke SendMessage,hGrd,GM_ADDROW,0,addr row
.endif
add ebx,sizeof NAMEMEM
.endw
.endif
add esi,sizeof PROJECT
.endw
mov esi,hMem
.while [esi].PROJECT.hmem
.if [esi].PROJECT.ntype==TPE_DIALOG && ![esi].PROJECT.delete
mov ebx,[esi].PROJECT.hmem
lea ebx,[ebx+sizeof DLGHEAD]
;Image
mov row[8],1
.while [ebx].DIALOG.hwnd
.if [ebx].DIALOG.hwnd!=-1
;lpName
lea eax,[ebx].DIALOG.idname
mov row[0],eax
mov row[12],eax
;lpID
lea eax,[ebx].DIALOG.id
mov row[4],eax
mov eax,[eax]
mov row[16],eax
invoke SendMessage,hGrd,GM_ADDROW,0,addr row
.endif
add ebx,sizeof DIALOG
.endw
.endif
add esi,sizeof PROJECT
.endw
mov esi,hMem
.while [esi].PROJECT.hmem
.if [esi].PROJECT.ntype==TPE_MENU && ![esi].PROJECT.delete
;Image
mov row[8],2
mov ebx,[esi].PROJECT.hmem
;lpName
lea eax,[ebx].MNUHEAD.menuname
mov row[0],eax
mov row[12],eax
;lpID
lea eax,[ebx].MNUHEAD.menuid
mov row[4],eax
mov eax,[eax]
mov row[16],eax
invoke SendMessage,hGrd,GM_ADDROW,0,addr row
lea ebx,[ebx+sizeof MNUHEAD]
.while [ebx].MNUITEM.itemflag
.if [ebx].MNUITEM.itemname || [ebx].MNUITEM.itemid
;lpName
lea eax,[ebx].MNUITEM.itemname
mov row[0],eax
mov row[12],eax
;lpID
lea eax,[ebx].MNUITEM.itemid
mov row[4],eax
mov eax,[eax]
mov row[16],eax
invoke SendMessage,hGrd,GM_ADDROW,0,addr row
.endif
add ebx,sizeof MNUITEM
.endw
.endif
add esi,sizeof PROJECT
.endw
mov esi,hMem
.while [esi].PROJECT.hmem
.if [esi].PROJECT.ntype==TPE_RESOURCE && ![esi].PROJECT.delete
mov ebx,[esi].PROJECT.hmem
;Image
mov row[8],3
.while [ebx].RESOURCEMEM.szname || [ebx].RESOURCEMEM.value
;lpName
lea eax,[ebx].RESOURCEMEM.szname
mov row[0],eax
mov row[12],eax
;lpID
lea eax,[ebx].RESOURCEMEM.value
mov row[4],eax
mov eax,[eax]
mov row[16],eax
invoke SendMessage,hGrd,GM_ADDROW,0,addr row
add ebx,sizeof RESOURCEMEM
.endw
.endif
add esi,sizeof PROJECT
.endw
mov esi,hMem
.while [esi].PROJECT.hmem
.if [esi].PROJECT.ntype==TPE_STRING && ![esi].PROJECT.delete
mov ebx,[esi].PROJECT.hmem
;Image
mov row[8],6
.while [ebx].STRINGMEM.szname || [ebx].STRINGMEM.value
;lpName
lea eax,[ebx].STRINGMEM.szname
mov row[0],eax
mov row[12],eax
;lpID
lea eax,[ebx].STRINGMEM.value
mov row[4],eax
mov eax,[eax]
mov row[16],eax
invoke SendMessage,hGrd,GM_ADDROW,0,addr row
add ebx,sizeof STRINGMEM
.endw
.endif
add esi,sizeof PROJECT
.endw
mov esi,hMem
.while [esi].PROJECT.hmem
.if [esi].PROJECT.ntype==TPE_ACCEL && ![esi].PROJECT.delete
mov ebx,[esi].PROJECT.hmem
;Image
mov row[8],4
.while [ebx].ACCELMEM.szname || [ebx].ACCELMEM.value
;lpName
lea eax,[ebx].ACCELMEM.szname
mov row[0],eax
mov row[12],eax
;lpID
lea eax,[ebx].ACCELMEM.value
mov row[4],eax
mov eax,[eax]
mov row[16],eax
invoke SendMessage,hGrd,GM_ADDROW,0,addr row
add ebx,sizeof ACCELMEM
.endw
.endif
add esi,sizeof PROJECT
.endw
invoke SendMessage,hGrd,GM_SETCURSEL,3,0
invoke SetFocus,hGrd
xor eax,eax
jmp Ex
.elseif eax==WM_COMMAND
invoke GetDlgItem,hWin,IDC_GRDNME
mov hGrd,eax
mov edx,wParam
movzx eax,dx
shr edx,16
.if edx==BN_CLICKED
.if eax==IDOK
invoke UpdateNames,hWin
invoke SendMessage,hWin,WM_CLOSE,NULL,NULL
.elseif eax==IDCANCEL
invoke SendMessage,hWin,WM_CLOSE,NULL,NULL
.elseif eax==IDC_BTNNMEADD
invoke SendMessage,hGrd,GM_ADDROW,0,NULL
invoke SendMessage,hGrd,GM_SETCURSEL,3,eax
invoke SetFocus,hGrd
xor eax,eax
jmp Ex
.elseif eax==IDC_BTNNMEDEL
invoke SendMessage,hGrd,GM_GETCURROW,0,0
push eax
invoke SendMessage,hGrd,GM_DELROW,eax,0
pop eax
invoke SendMessage,hGrd,GM_SETCURSEL,3,eax
invoke SetFocus,hGrd
xor eax,eax
jmp Ex
.elseif eax==IDC_BTNNMEEXPORT
invoke SaveNamesToFile,hWin
invoke SetFocus,hGrd
xor eax,eax
jmp Ex
.endif
.endif
.elseif eax==WM_NOTIFY
invoke GetDlgItem,hWin,IDC_GRDNME
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
.elseif eax==GN_BEFORESELCHANGE
;Restrict to gol 3 & 4
.if [esi].GRIDNOTIFY.col<3
mov [esi].GRIDNOTIFY.col,3
.endif
;Enable / Disable delete button
invoke GetDlgItem,hWin,IDC_BTNNMEDEL
push eax
mov ecx,[esi].GRIDNOTIFY.row
shl ecx,16
add ecx,2
invoke SendMessage,hGrd,GM_GETCELLDATA,ecx,addr buffer
pop edx
mov eax,dword ptr buffer
.if eax
xor eax,eax
.else
inc eax
.endif
invoke EnableWindow,edx,eax
.endif
.endif
.elseif eax==WM_CLOSE
invoke EndDialog,hWin,wParam
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
Ex:
ret
NameEditProc endp
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -