_CheckModify proc
local @dwReturn
mov @dwReturn;TRUE
invoke SendMessage;hWinEdit;EM_GETMODIFY;0;0
。if eax && hFile
invoke MessageBox;hWinMain;addr szModify;
addr szCaptionMain;
MB_YESNOCANCEL or MB_ICONQUESTION
。if eax IDYES
call _SaveFile
。elseif eax IDCANCEL
mov @dwReturn;FALSE
。endif
。endif
mov eax;@dwReturn
ret
_CheckModify endp
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
; 查找文字
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
_FindText proc
local @stFindText:FINDTEXTEX
;********************************************************************
; 设置查找范围
;********************************************************************
invoke SendMessage;hWinEdit;EM_EXGETSEL;
0;addr @stFindText。chrg
来源:电子工业出版社 作者:罗云彬 上一页 回书目 下一页
上一页 回书目 下一页
第9章 通用控件
9。4 使用Richedit控件(3)
。if stFind。Flags & FR_DOWN
push @stFindText。chrg。cpMax
pop @stFindText。chrg。cpMin
。endif
mov @stFindText。chrg。cpMax;…1
;********************************************************************
; 设置查找选项
;********************************************************************
mov @stFindText。lpstrText;offset szFindText
mov ecx;stFind。Flags
and ecx;FR_MATCHCASE or FR_DOWN or FR_WHOLEWORD
;********************************************************************
; 查找并把光标设置到找到的文本上
;********************************************************************
invoke SendMessage;hWinEdit;EM_FINDTEXTEX;
ecx;addr @stFindText
。if eax …1
mov ecx;hWinMain
。if hFindDialog
mov ecx;hFindDialog
。endif
invoke MessageBox;ecx;addr szNotFound;NULL;
MB_OK or MB_ICONINFORMATION
ret
。endif
invoke SendMessage;hWinEdit;EM_EXSETSEL;
0;addr @stFindText。chrgText
invoke SendMessage;hWinEdit;EM_SCROLLCARET;NULL;NULL
ret
_FindText endp
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
; 根据情况改变菜单项状态
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
_SetStatus proc
local @stRange:CHARRANGE
invoke SendMessage;hWinEdit;EM_EXGETSEL;0;addr @stRange
;********************************************************************
mov eax;@stRange。cpMin
。if eax @stRange。cpMax
invoke EnableMenuItem;hMenu;IDM_COPY;MF_GRAYED
invoke EnableMenuItem;hMenu;IDM_CUT;MF_GRAYED
。else
invoke EnableMenuItem;hMenu;IDM_COPY;MF_ENABLED
invoke EnableMenuItem;hMenu;IDM_CUT;MF_ENABLED
。endif
;********************************************************************
invoke SendMessage;hWinEdit;EM_CANPASTE;0;0
。if eax
invoke EnableMenuItem;hMenu;IDM_PASTE;MF_ENABLED
。else
invoke EnableMenuItem;hMenu;IDM_PASTE;MF_GRAYED
。endif
;********************************************************************
invoke SendMessage;hWinEdit;EM_CANREDO;0;0
。if eax
invoke EnableMenuItem;hMenu;IDM_REDO;MF_ENABLED
。else
invoke EnableMenuItem;hMenu;IDM_REDO;MF_GRAYED
。endif
;********************************************************************
invoke SendMessage;hWinEdit;EM_CANUNDO;0;0
。if eax
invoke EnableMenuItem;hMenu;IDM_UNDO;MF_ENABLED
。else
invoke EnableMenuItem;hMenu;IDM_UNDO;MF_GRAYED
。endif
;********************************************************************
invoke GetWindowTextLength;hWinEdit
。if eax
invoke EnableMenuItem;hMenu;IDM_SELALL;MF_ENABLED
。else
invoke EnableMenuItem;hMenu;IDM_SELALL;MF_GRAYED
。endif
;********************************************************************
invoke SendMessage;hWinEdit;EM_GETMODIFY;0;0
。if eax && hFile
invoke EnableMenuItem;hMenu;IDM_SAVE;MF_ENABLED
。else
invoke EnableMenuItem;hMenu;IDM_SAVE;MF_GRAYED
。endif
;********************************************************************
。if szFindText
invoke EnableMenuItem;hMenu;IDM_FINDNEXT;MF_ENABLED
invoke EnableMenuItem;hMenu;IDM_FINDPREV;MF_ENABLED
。else
invoke EnableMenuItem;hMenu;IDM_FINDNEXT;MF_GRAYED
invoke EnableMenuItem;hMenu;IDM_FINDPREV;MF_GRAYED
。endif
;********************************************************************
ret
_SetStatus endp
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
_Init proc
local @stCf:CHARFORMAT
;********************************************************************
; 注册“查找”对话框消息,初始化“查找”对话框的结构
;********************************************************************
push hWinMain
pop stFind。hwndOwner
invoke RegisterWindowMessage;addr FINDMSGSTRING
mov idFindMessage;eax
;********************************************************************
; 建立输出文本窗口
;********************************************************************
invoke CreateWindowEx;WS_EX_CLIENTEDGE;offset szClassEdit;
NULL;WS_CHILD OR WS_VISIBLE OR WS_VSCROLL
OR WS_HSCROLL OR ES_MULTILINE or ES_NOHIDESEL;
0;0;0;0;hWinMain;0;hInstance;NULL
mov hWinEdit;eax
invoke SendMessage;hWinEdit;EM_SETTEXTMODE;TM_PLAINTEXT;0
invoke RtlZeroMemory;addr @stCf;sizeof @stCf
mov @stCf。cbSize;sizeof @stCf
mov @stCf。yHeight;9 * 20
mov @stCf。dwMask;CFM_FACE or CFM_SIZE or CFM_BOLD
invoke lstrcpy;addr @stCf。szFaceName;addr szFont
invoke SendMessage;hWinEdit;EM_SETCHARFORMAT;0;addr @stCf
invoke SendMessage;hWinEdit;EM_EXLIMITTEXT;0;…1
ret
_Init endp
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
_Quit proc
invoke _CheckModify
。if eax
invoke DestroyWindow;hWinMain
in
小提示:按 回车 [Enter] 键 返回书目,按 ← 键 返回上一页, 按 → 键 进入下一页。
赞一下
添加书签加入书架