按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!
ret
_OpenFile endp
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
; 选择颜色
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
_ChooseColor proc
local @stCC:CHOOSECOLOR
invoke RtlZeroMemory;addr @stCC;sizeof @stCC
mov @stCC。lStructSize;sizeof @stCC
push hWinMain
pop @stCC。hwndOwner
push dwBackColor
pop @stCC。rgbResult
mov @stCC。Flags;CC_RGBINIT or CC_FULLOPEN
mov @stCC。lpCustColors;offset dwCustColors
invoke ChooseColor;addr @stCC
。if eax
push @stCC。rgbResult
pop dwBackColor
invoke wsprintf;addr szBuffer;addr szFormatColor;
dwBackColor
invoke MessageBox;hWinMain;addr szBuffer;
addr szCaption;MB_OK
。endif
ret
_ChooseColor endp
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
; 选择字体
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
_ChooseFont proc
local @stCF:CHOOSEFONT
invoke RtlZeroMemory;addr @stCF;sizeof @stCF
mov @stCF。lStructSize;sizeof @stCF
push hWinMain
pop @stCF。hwndOwner
mov @stCF。lpLogFont;offset stLogFont
push dwFontColor
pop @stCF。rgbColors
mov @stCF。Flags;CF_SCREENFONTS or CF_INITTOLOGFONTSTRUCT
or CF_EFFECTS
invoke ChooseFont;addr @stCF
。if eax
push @stCF。rgbColors
pop dwFontColor
mov eax;@stCF。iPointSize
shl eax;1
invoke wsprintf;addr szBuffer;addr szFormatFont;
addr stLogFont。lfFaceName;
dwFontColor;eax
invoke MessageBox;hWinMain;addr szBuffer;
addr szCaption;MB_OK
。endif
ret
_ChooseFont endp
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
_ProcDlgMain proc uses ebx edi esi hWnd;wMsg;wParam;lParam
local @szBuffer'128':byte
mov eax;wMsg
。if eax WM_CLOSE
invoke EndDialog;hWnd;NULL
。elseif eax WM_INITDIALOG
;********************************************************************
; 注册“查找”对话框消息,初始化“查找”对话框的结构
;********************************************************************
mov eax;hWnd
mov hWinMain;eax
mov stFind。hwndOwner;eax
mov stFind。lStructSize;sizeof stFind
来源:电子工业出版社 作者:罗云彬 上一页 回书目 下一页
上一页 回书目 下一页
第8章 通用对话框
8。1 通用对话框简介(3)
mov stFind。Flags;FR_DOWN
mov stFind。lpstrFindWhat;offset szFindText
mov stFind。wFindWhatLen;sizeof szFindText
mov stFind。lpstrReplaceWith;offset szReplaceText
mov stFind。wReplaceWithLen;sizeof szReplaceText
invoke RegisterWindowMessage;addr FINDMSGSTRING
mov idFindMessage;eax
。elseif eax WM_MAND
mov eax;wParam
。if ax IDM_EXIT
invoke EndDialog;hWnd;NULL
。elseif ax IDM_OPEN
invoke _OpenFile
。elseif ax IDM_SAVEAS
invoke _SaveAs
。elseif ax IDM_PAGESETUP
invoke _PageSetup
。elseif ax IDM_FIND
and stFind。Flags;not FR_DIALOGTERM
invoke FindText;addr stFind
。elseif ax IDM_REPLACE
and stFind。Flags;not FR_DIALOGTERM
invoke ReplaceText;addr stFind
。elseif ax IDM_SELFONT
invoke _ChooseFont
。elseif ax IDM_SELCOLOR
invoke _ChooseColor
。endif
;********************************************************************
。elseif eax idFindMessage
xor ecx;ecx
。if stFind。Flags & FR_FINDNEXT
mov ecx;offset szFindNext
。elseif stFind。Flags & FR_REPLACE
mov ecx;offset szReplace
。elseif stFind。Flags & FR_REPLACEALL
mov ecx;offset szReplaceAll
。endif
。if ecx
invoke wsprintf;addr szBuffer;
addr szFormatFind;
ecx;addr szFindText;addr szReplaceText
invoke MessageBox;hWinMain;addr szBuffer;
addr szCaption;MB_OK
。endif
;********************************************************************
。else
mov eax;FALSE
ret
。endif
mov eax;TRUE
ret
_ProcDlgMain endp
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
start:
invoke GetModuleHandle;NULL
mov hInstance;eax
invoke DialogBoxParam;hInstance;DLG_MAIN;NULL;
offset _ProcDlgMain;NULL
invoke ExitProcess;NULL
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
end start
资源脚本文件mDlg。rc的内容如下:
//》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
#include
//》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
#define ICO_MAIN 1000
#define DLG_MAIN 1000
#define IDM_MAIN 1000
#define IDM_OPEN 1101
#define IDM_SAVEAS 1102
#define IDM_PAGESETUP 1103
#define IDM_EXIT 1104
#define IDM_FIND 1201
#define IDM_REPLACE 1202
#define IDM_SELFONT 1203
#define IDM_SELCOLOR 1204
//》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
ICO_MAIN ICON 〃Main。ico〃
//》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
DLG_MAIN DIALOG 193; 180; 310; 134
MENU IDM_MAIN
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU | WS_THICKFRAME
CAPTION 〃通用对话框示例〃
FONT 9; 〃宋体〃
{
}
//》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
IDM_MAIN menu discardable
BEGIN
popup 〃文件(&F)〃
BEGIN
menuitem 〃打开文件(&O)。。。〃; IDM_OPEN
menuitem 〃文件另存为(&C)。。。〃;IDM_SAVEAS
menuitem separator
menuitem 〃页面设置(&P)。。。〃;IDM_PAGESETUP
menuitem separator
menuitem 〃退出(&X)〃; IDM_EXIT
END
popup 〃查看(&V)〃
BEGIN
menuitem 〃查找字符串(&S)。。。〃;IDM_FIND
menuitem 〃替换字符串(&R)。。。〃;IDM_REPLACE
menuitem separator
menuitem 〃选择字体(&F)。。。〃;IDM_SELFONT
menuitem 〃选择颜色(&B)。。。〃;IDM_SELCOLOR
END
END
//》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
在资源脚本文件中定义了一个对话框用做主窗口,同时定义了一个菜单用来选择各种通用对话框。下面结合这个例子说明各种通用对话框的�