?? 多個文件的工程---增強poppad.txt
字號:
mov ebx,MF_GRAYED
.else
mov ebx,MF_ENABLED
.endif
mov iEnable ,ebx
mov iSelBeg ,ebx
invoke EnableMenuItem,wParam, IDM_EDIT_CUT, iEnable
invoke EnableMenuItem,wParam, IDM_EDIT_COPY, iEnable
invoke EnableMenuItem,wParam, IDM_EDIT_CLEAR, iEnable
.elseif eax==2 ;Search menu
; Enable Find, Next, and Replace if modeless
; dialogs are not already active
.if (hDlgModeless == NULL)
mov ebx,MF_ENABLED
.else
mov ebx,MF_GRAYED
.endif
mov iEnable , ebx
invoke EnableMenuItem ,wParam, IDM_SEARCH_FIND, iEnable
invoke EnableMenuItem ,wParam, IDM_SEARCH_NEXT, iEnable
invoke EnableMenuItem ,wParam, IDM_SEARCH_REPLACE, iEnable
.endif
xor eax,eax
ret
.elseif message == WM_COMMAND
; Messages from edit control
mov eax,wParam
.if (lParam!=FALSE)&&(ax==EDITID)
mov eax,wParam
shr eax,16
.if eax==EN_UPDATE
mov bNeedSave,TRUE
xor eax,eax
ret
.elseif (eax==EN_ERRSPACE)||(eax==EN_MAXTEXT)
invoke MessageBox,hwnd, CTXT ("Edit control out of space."),addr szAppName, MB_OK or MB_ICONSTOP
xor eax,eax
ret
.endif
xor eax,eax
ret
.endif
; Messages from File menu
mov eax,wParam
.if ax==IDM_FILE_NEW
.if (bNeedSave!=FALSE)
invoke AskAboutSave,hwnd,addr szTitleName
.if (eax==IDCANCEL)
xor eax,eax
ret
.endif
.endif
invoke SetWindowText,hwndEdit,addr nullStr
lea esi,szFileName
mov BYTE ptr [esi],0
lea esi,szTitleName
mov BYTE ptr [esi],0
invoke DoCaption,hwnd,addr szTitleName
mov bNeedSave,FALSE ;
xor eax,eax
ret
.elseif ax==IDM_FILE_OPEN
.if (bNeedSave!=FALSE)
invoke AskAboutSave,hwnd, addr szTitleName
.if (eax==IDCANCEL)
xor eax,eax
ret
.endif
.endif
invoke PopFileOpenDlg,hwnd,addr szFileName,addr szTitleName
.if (eax!=FALSE)
invoke PopFileRead,hwndEdit,addr szFileName
.if (eax==FALSE)
invoke OkMessage,hwnd, CTEXT ("Could not read file %s!"),addr szTitleName
mov szFileName[0],0
mov szTitleName[0],0
.endif
.endif
invoke DoCaption,hwnd,addr szTitleName
mov eax,FALSE
mov bNeedSave,eax
xor eax,eax
ret
.elseif eax==IDM_FILE_SAVE
mov al,szFileName[0]
.if (al!=FALSE)
invoke PopFileWrite,hwndEdit, szFileName
.if (eax!=FALSE)
mov bNeedSave,FALSE
mov eax,1
ret
.else
invoke OkMessage,hwnd, CTEXT ("Could not write file %s"),addr szTitleName
xor eax,eax
ret
.endif
.endif
;fall through
jmp @f
.elseif eax==IDM_FILE_SAVE_AS
@@:
invoke PopFileSaveDlg,hwnd,addr szFileName,addr szTitleName
.if (eax!=FALSE)
invoke DoCaption,hwnd,addr szTitleName
invoke PopFileWrite,hwndEdit,addr szFileName
.if eax!=FALSE
mov eax,FALSE
mov bNeedSave,eax
mov eax,1
ret
.else
invoke OkMessage,hwnd, CTEXT ("Could not write file %s"),addr szTitleName
xor eax,eax
ret
.endif
.endif
xor eax,eax
ret
.elseif eax==IDM_FILE_PRINT
invoke PopPrntPrintFile,hInst, hwnd, hwndEdit,addr szTitleName
.if eax==FALSE
invoke OkMessage,hwnd, CTEXT ("Could not print file %s"),addr szTitleName
.endif
xor eax,eax
ret
.elseif eax==IDM_APP_EXIT
invoke SendMessage,hwnd, WM_CLOSE, 0, 0
xor eax,eax
ret
; Messages from Edit menu
.elseif eax==IDM_EDIT_UNDO
invoke SendMessage,hwndEdit, WM_UNDO, 0, 0
xor eax,eax
ret
.elseif eax==IDM_EDIT_CUT
invoke SendMessage,hwndEdit, WM_CUT, 0, 0
xor eax,eax
ret
.elseif eax==IDM_EDIT_COPY
invoke SendMessage,hwndEdit, WM_COPY, 0, 0
xor eax,eax
ret
.elseif eax==IDM_EDIT_PASTE
invoke SendMessage,hwndEdit, WM_PASTE, 0, 0
xor eax,eax
ret
.elseif eax==IDM_EDIT_CLEAR
invoke SendMessage,hwndEdit, WM_CLEAR, 0, 0
xor eax,eax
ret
.elseif eax==IDM_EDIT_SELECT_ALL
invoke SendMessage,hwndEdit, EM_SETSEL, 0, -1
xor eax,eax
ret
; Messages from Search menu
.elseif eax==IDM_SEARCH_FIND
invoke SendMessage,hwndEdit, EM_GETSEL, 0, addr iOffset
invoke PopFindFindDlg,hwnd
mov hDlgModeless,eax
xor eax,eax
ret
.elseif eax==IDM_SEARCH_NEXT
invoke SendMessage,hwndEdit, EM_GETSEL, 0,addr iOffset
invoke PopFindValidFind
.if (eax!=FALSE)
invoke PopFindNextText,hwndEdit,addr iOffset
.else
invoke PopFindFindDlg,hwnd
mov hDlgModeless,eax
.endif
xor eax,eax
ret
.elseif eax==IDM_SEARCH_REPLACE
invoke SendMessage,hwndEdit, EM_GETSEL, 0,addr iOffset
invoke PopFindReplaceDlg,hwnd
mov hDlgModeless,eax
xor eax,eax
ret
.elseif eax==IDM_FORMAT_FONT
invoke PopFontChooseFont,hwnd
.if eax!=FALSE
invoke PopFontSetFont,hwndEdit
.endif
xor eax,eax
ret
.elseif eax==IDM_HELP
invoke OkMessage,hwnd,CTXT ("Help not yet implemented!"),CTXT(" ")
xor eax,eax
ret
.elseif eax==IDM_APP_ABOUT
invoke DialogBoxParam,hInst, CTXT ("AboutBox"), hwnd,addr AboutDlgProc,0
xor eax,eax
ret
.endif
.elseif message == WM_CLOSE
.if (bNeedSave==FALSE)
invoke DestroyWindow,hwnd
.else
invoke AskAboutSave,hwnd,addr szTitleName
.if (eax!=IDCANCEL)
invoke DestroyWindow,hwnd
.endif
.endif
xor eax,eax
ret
.elseif message == WM_QUERYENDSESSION
.if (bNeedSave==FALSE)
mov eax,1
ret
.else
invoke AskAboutSave,hwnd,addr szTitleName
.if (eax!=IDCANCEL)
mov eax,1
ret
.else
xor eax,eax
.endif
.endif
ret
.elseif message == WM_DESTROY
invoke PopFontDeinitialize
invoke PostQuitMessage,NULL
xor eax,eax
ret
.else
; Process "Find-Replace" messages
mov eax,message
.if (eax == messageFindReplace)
mov eax,lParam
mov pfr,eax
mov esi,eax
mov eax,[esi+12]
and eax,FR_DIALOGTERM
.if (eax!=FALSE)
mov hDlgModeless,NULL
.endif
mov esi,pfr
mov eax,[esi+12]
and eax,FR_FINDNEXT
.if (eax!=FALSE)
invoke wsprintf,addr szTitleName,CTEXT("%d"),iOffset
invoke MessageBox,hwnd,addr szTitleName,NULL,MB_OK
invoke PopFindFindText,hwndEdit,addr iOffset,pfr
.if (eax==FALSE)
invoke OkMessage,hwnd, CTEXT ("Text not found!"),addr nullStr
.endif
.endif
mov esi,pfr
mov eax,[esi+12]
and eax,FR_REPLACE
mov ebx,[esi+12]
and ebx,FR_REPLACE
.if (eax!=FALSE) || (ebx!=FALSE)
invoke PopFindReplaceText,hwndEdit,addr iOffset, pfr
.if (eax==FALSE)
invoke OkMessage,hwnd, CTEXT ("Text not found!"),addr nullStr
.endif
.endif
mov esi,pfr
mov eax,[esi+12]
and eax,FR_REPLACEALL
.if (eax!=FALSE)
@@:
invoke PopFindReplaceText,hwndEdit,addr iOffset, pfr
cmp eax,FALSE
jNz @b
.endif
xor eax,eax
ret
.endif
.endif
invoke DefWindowProc,hwnd,message,wParam,lParam
ret
WndProc endp
AboutDlgProc proc hDlg:HWND,message:UINT,wParam:WPARAM,lParam:LPARAM
mov eax,message
.if eax==WM_INITDIALOG
mov eax,TRUE
ret
.elseif eax==WM_COMMAND
mov eax,wParam
and eax,0FFFFh
.if eax==IDOK
invoke EndDialog,hDlg, 0
mov eax,TRUE
.endif
.endif
mov eax,FALSE
ret
AboutDlgProc endp
END START
POPFILE.ASM
.386
.Model Flat, StdCall
Option Casemap :None
include windows.inc
include comdlg32.inc
include gdi32.inc
include user32.inc
include kernel32.inc
include shlwapi.inc
include advapi32.inc
includelib advapi32.lib
includelib comdlg32.lib
includelib shlwapi.lib
CTEXT macro Text
local szText
.data
szText byte Text, 0
.code
exitm <offset szText>
endm
.data
szFilter db "Text Files (*.TXT)",0,"*.txt",0,\
"ASCII Files (*.ASC)",0,"*.asc",0,\
"All Files (*.*)",0,"*.*",0,0
.data?
szBuffer db 1000 dup(0)
ofn OPENFILENAME <?>
.code
PopFileInitialize proc hwnd:HWND
mov ofn.lStructSize,sizeof (OPENFILENAME) ;
mov eax, hwnd
mov ofn.hwndOwner,eax
mov ofn.hInstance,NULL ;
mov eax,offset szFilter
mov ofn.lpstrFilter,eax
mov ofn.lpstrCustomFilter,NULL
mov ofn.nMaxCustFilter,0
mov ofn.nFilterIndex,0
mov ofn.lpstrFile,NULL ; // Set in Open and Close functions
mov ofn.nMaxFile,MAX_PATH
mov ofn.lpstrFileTitle,NULL ; // Set in Open and Close functions
mov ofn.nMaxFileTitle,MAX_PATH
mov ofn.lpstrInitialDir,NULL ;
mov ofn.lpstrTitle,NULL ;
mov ofn.Flags,0 ; // Set in Open and Close functions
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -