?? 多個(gè)文件的工程---增強(qiáng)poppad.txt
字號(hào):
mov ofn.nFileOffset,0 ;
mov ofn.nFileExtension,0 ;
mov ofn.lpstrDefExt,CTEXT ("txt")
mov ofn.lCustData,0
mov ofn.lpfnHook,NULL
mov ofn.lpTemplateName,NULL
ret
PopFileInitialize endp
PopFileOpenDlg proc hwnd:HWND,pstrFileName:PTSTR , pstrTitleName:PTSTR
mov eax,hwnd
mov ofn.hwndOwner,eax
mov eax,pstrFileName
mov ofn.lpstrFile,eax
mov eax,pstrTitleName
mov ofn.lpstrFileTitle,eax
mov ofn.Flags,OFN_HIDEREADONLY or OFN_CREATEPROMPT
invoke GetOpenFileName,addr ofn
ret
PopFileOpenDlg endp
PopFileRead proc hwndEdit:HWND,pstrFileName:PTSTR
LOCAL bySwap:BYTE
LOCAL dwBytesRead:DWORD
LOCAL hFile:HANDLE
LOCAL i, iFileLength, iUniTest:DWORD
LOCAL pBuffer, pText, pConv:PBYTE
; Open the file.
invoke CreateFile,pstrFileName, GENERIC_READ, FILE_SHARE_READ,NULL, OPEN_EXISTING, 0, NULL
mov hFile,eax
.if (eax==INVALID_HANDLE_VALUE)
mov eax,FALSE
ret
.endif
; Get file size in bytes and allocate memory for read.
; Add an extra two bytes for zero termination.
invoke GetFileSize,hFile, NULL
mov iFileLength,eax
add eax,2
invoke LocalAlloc,LMEM_FIXED or LMEM_ZEROINIT,eax
mov pBuffer,eax
; Read file and put terminating zeros at end.
invoke ReadFile,hFile, pBuffer, iFileLength,addr dwBytesRead, NULL
invoke CloseHandle,hFile
mov ebx,iFileLength
mov esi,pBuffer
add esi,ebx
xor ax,ax
mov [esi],ax
;invoke MessageBox,hwndEdit, CTEXT ("33333333333"),NULL, MB_OK
; Test to see if the text is Unicode
mov iUniTest,IS_TEXT_UNICODE_SIGNATURE or IS_TEXT_UNICODE_REVERSE_SIGNATURE
invoke IsTextUnicode,pBuffer,iFileLength,addr iUniTest
.if (eax!=FALSE)
invoke MessageBox,hwndEdit, CTEXT ("1111111111"),NULL, MB_OK
mov eax,pBuffer
add eax,2
mov pText,eax
sub iFileLength,2
mov eax,iUniTest
and eax,IS_TEXT_UNICODE_REVERSE_SIGNATURE
.if eax!=FALSE
mov i,0
nexti:
mov esi,pText
mov ebx,i
shl ebx,1
add esi,ebx
mov al,[esi]
mov bySwap,al
mov eax,[esi+1]
mov [esi],eax
mov al,bySwap
mov [esi+1],al
mov eax,iFileLength
shr eax,1
.if (eax>i)
jmp nexti
.endif
.endif
;Allocate memory for possibly converted string
invoke LocalAlloc,LMEM_FIXED or LMEM_ZEROINIT,iFileLength + 2
mov pConv,eax
; If the edit control is not Unicode, convert Unicode text to
; non-Unicode (i.e., in general, wide character).
;#ifndef UNICODE
; WideCharToMultiByte (CP_ACP, 0, (PWSTR) pText, -1, pConv,
; iFileLength + 2, NULL, NULL) ;
; // If the edit control is Unicode, just copy the string
;#else
; lstrcpy ((PTSTR) pConv, (PTSTR) pText) ;
;#endif
.else ; the file is not Unicode
invoke MessageBox,hwndEdit, CTEXT ("2222222222"),NULL, MB_OK
mov eax,pBuffer
mov pText,eax
; Allocate memory for possibly converted string.
mov eax,iFileLength
shl eax,1
add eax,2
invoke LocalAlloc,LMEM_FIXED or LMEM_ZEROINIT,eax
mov pConv,eax
; If the edit control is Unicode, convert ASCII text.
mov eax,iFileLength
inc eax
shl eax,1
invoke MultiByteToWideChar,CP_ACP, 0,pText, -1,pConv, eax
;#ifdef UNICODE
; MultiByteToWideChar (CP_ACP, 0, pText, -1, (PTSTR) pConv,
; iFileLength + 1) ;
; // If not, just copy buffer
;#else
; lstrcpy ((PTSTR) pConv, (PTSTR) pText) ;
;#endif
.endif
invoke SetWindowTextW,hwndEdit,pConv
invoke LocalFree,pBuffer
invoke LocalFree,pConv
mov eax,TRUE
ret
PopFileRead endp
PopFileSaveDlg proc hwnd:HWND, pstrFileName:PTSTR, pstrTitleName:PTSTR
mov eax,hwnd
mov ofn.hwndOwner,eax
mov eax,pstrFileName
mov ofn.lpstrFile,eax
mov eax,pstrTitleName
mov ofn.lpstrFileTitle,eax
mov ofn.Flags,OFN_OVERWRITEPROMPT ;
invoke GetSaveFileName,addr ofn
ret
PopFileSaveDlg endp
PopFileWrite proc hwndEdit:HWND, pstrFileName:PTSTR
LOCAL dwBytesWritten:DWORD
LOCAL hFile:HANDLE
LOCAL iLength:DWORD
LOCAL pstrBuffer:PTSTR
wByteOrderMark = 0FEFFh
invoke CreateFile,pstrFileName, GENERIC_WRITE, 0,NULL, CREATE_ALWAYS, 0, NULL
mov hFile,eax
;Open the file, creating it if necessary
.if (eax==INVALID_HANDLE_VALUE)
mov eax,FALSE
ret
.endif
;Get the number of characters in the edit control and allocate
;memory for them.
invoke GetWindowTextLength,hwndEdit
mov iLength,eax
inc eax
mov ecx,sizeof (TCHAR)
mul ecx
invoke LocalAlloc,LMEM_FIXED or LMEM_ZEROINIT,eax
mov pstrBuffer,eax
.if (eax==FALSE)
invoke CloseHandle,hFile
mov eax,FALSE
ret
.endif
;If the edit control will return Unicode text, write the
;byte order mark to the file.
;#ifdef UNICODE
; WriteFile (hFile, &wByteOrderMark, 2, &dwBytesWritten, NULL) ;
;#endif
;Get the edit buffer and write that out to the file.
invoke GetWindowText,hwndEdit, pstrBuffer, iLength + 1
mov iLength,eax
mov ecx,sizeof (TCHAR)
mul ecx
mov ecx,eax
push ecx
invoke WriteFile,hFile, pstrBuffer, ecx,addr dwBytesWritten, NULL
pop ecx
.if (ecx!= dwBytesWritten)
invoke CloseHandle,hFile
invoke LocalFree,pstrBuffer
mov eax,FALSE
ret
.endif
invoke CloseHandle,hFile
invoke LocalFree,pstrBuffer
mov eax,TRUE
ret
PopFileWrite endp
end
POPFONT.ASM
.386
.Model Flat, StdCall
Option Casemap :None
include windows.inc
include comdlg32.inc
include gdi32.inc
include user32.inc
includelib comdlg32.lib
.data?
logfont LOGFONT <?>
hFont HFONT ?
.code
PopFontChooseFont proc hwnd:HWND
LOCAL cf:CHOOSEFONTA
mov cf.lStructSize,sizeof (CHOOSEFONT)
mov eax,hwnd
mov cf.hwndOwner,eax
mov cf.hDC,NULL
mov eax,offset logfont
mov cf.lpLogFont,eax
mov cf.iPointSize,0 ;
mov cf.Flags,CF_INITTOLOGFONTSTRUCT or CF_SCREENFONTS or CF_EFFECTS ;
mov cf.rgbColors,0 ;
mov cf.lCustData,0 ;
mov cf.lpfnHook,NULL ;
mov cf.lpTemplateName,NULL ;
mov cf.hInstance,NULL ;
mov cf.lpszStyle,NULL ;
mov cf.nFontType,0 ; // Returned from ChooseFont
mov cf.nSizeMin,0 ;
mov cf.nSizeMax,0 ;
invoke ChooseFont,addr cf
ret
PopFontChooseFont endp
PopFontInitialize proc hwndEdit:HWND
invoke GetStockObject,SYSTEM_FONT
mov ebx,eax
invoke GetObject,ebx, sizeof(LOGFONT),addr logfont
invoke CreateFontIndirect,addr logfont
mov hFont,eax
invoke SendMessage,hwndEdit, WM_SETFONT, hFont, 0
ret
PopFontInitialize endp
PopFontSetFont proc hwndEdit:HWND
LOCAL hFontNew:HFONT
LOCAL rect:RECT
invoke CreateFontIndirect,addr logfont
mov hFontNew,eax
invoke SendMessage,hwndEdit, WM_SETFONT,hFontNew, 0
invoke DeleteObject,hFont
mov eax,hFontNew
mov hFont,eax
invoke GetClientRect,hwndEdit,addr rect
invoke InvalidateRect,hwndEdit,addr rect, TRUE
ret
PopFontSetFont endp
PopFontDeinitialize proc
invoke DeleteObject,hFont
ret
PopFontDeinitialize endp
end
POPFIND.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
includelib comdlg32.lib
includelib shlwapi.lib
CTEXT macro Text
local szText
.data
szText byte Text, 0
.code
exitm <offset szText>
endm
MAX_STRING_LEN equ 256
.data?
szFindText TCHAR MAX_STRING_LEN dup(?)
szReplText TCHAR MAX_STRING_LEN dup(?)
frFindDlg FINDREPLACE <?> ; // must be static for modeless dialog!!!
frReplaceDlg FINDREPLACE <?> ; // must be static for modeless dialog!!!
.code
PopFindFindDlg proc hwnd:HWND
mov frFindDlg.lStructSize,sizeof (FINDREPLACE)
mov eax,hwnd
mov frFindDlg.hwndOwner,eax
mov frFindDlg.hInstance,NULL
mov frFindDlg.Flags,FR_HIDEUPDOWN or FR_HIDEMATCHCASE or FR_HIDEWHOLEWORD
mov eax,offset szFindText
mov frFindDlg.lpstrFindWhat,eax
mov frFindDlg.lpstrReplaceWith,NULL
mov frFindDlg.wFindWhatLen,MAX_STRING_LEN
mov frFindDlg.wReplaceWithLen,0
mov frFindDlg.lCustData,0
mov frFindDlg.lpfnHook,NULL
mov frFindDlg.lpTemplateName,NULL
invoke FindText,addr frFindDlg
ret
PopFindFindDlg endp
PopFindReplaceDlg proc hwnd:HWND
mov frReplaceDlg.lStructSize,sizeof (FINDREPLACE)
mov eax,hwnd
mov frReplaceDlg.hwndOwner,eax
mov frReplaceDlg.hInstance,NULL ;
mov frReplaceDlg.Flags,FR_HIDEUPDOWN or FR_HIDEMATCHCASE or FR_HIDEWHOLEWORD
mov eax,offset szFindText
mov frReplaceDlg.lpstrFindWhat,eax
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -