按键盘上方向键 ← 或 → 可快速上下翻页,按键盘上的 Enter 键可回到本书目录页,按键盘上方向键 ↑ 可回到本页顶部!
————未阅读完?加入书签已便下次继续阅读!
szText1 db 'Hello; World!';0
szText2 db '嘿,你看到标题栏变了吗?';0
szText3 db '自定义';0
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
; 代码段
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
de
;》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》
_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
invoke DeleteObject;hBmp1
invoke DeleteObject;hBmp2
。elseif eax WM_INITDIALOG
;********************************************************************
; 设置标题栏图标
;********************************************************************
invoke LoadIcon;hInstance;ICO_MAIN
invoke SendMessage;hWnd;WM_SETICON;ICON_BIG;eax
;********************************************************************
; 初始化组合框
;********************************************************************
invoke SendDlgItemMessage;hWnd;
IDC_TITLETEXT;CB_ADDSTRING;0;addr szText1
invoke SendDlgItemMessage;hWnd;
IDC_TITLETEXT;CB_ADDSTRING;0;addr szText2
invoke SendDlgItemMessage;hWnd;
IDC_TITLETEXT;CB_ADDSTRING;0;addr szText3
invoke SendDlgItemMessage;hWnd;
IDC_TITLETEXT;CB_SETCURSEL;0;0
invoke GetDlgItem;hWnd;IDC_CUSTOMTEXT
invoke EnableWindow;eax;FALSE
invoke LoadBitmap;hInstance;IDB_1
mov hBmp1;eax
invoke LoadBitmap;hInstance;IDB_2
mov hBmp2;eax
;********************************************************************
; 初始化单选钮和复选框
;********************************************************************
invoke CheckDlgButton;hWnd;IDC_SHOWBMP;BST_CHECKED
invoke CheckDlgButton;hWnd;IDC_ALOW;BST_CHECKED
invoke CheckDlgButton;hWnd;
IDC_THICKFRAME;BST_CHECKED
;********************************************************************
; 初始化滚动条
;********************************************************************
invoke SendDlgItemMessage;hWnd;
IDC_SCROLL;SBM_SETRANGE;0;100
;********************************************************************
。elseif eax WM_MAND
mov ax;wParam
;********************************************************************
; 由于印刷宽度有限,WM_MAND消息处理代码的缩进格式有所影响,请读者注意
;********************************************************************
。if ax IDCANCEL
invoke EndDialog;hWnd;NULL
invoke DeleteObject;hBmp1
invoke DeleteObject;hBmp2
;********************************************************************
; 更换图片
;********************************************************************
。elseifax IDOK
mov eax;hBmp1
xchg eax;hBmp2
mov hBmp1;eax
invoke SendDlgItemMessage;hWnd;IDC_BMP;STM_SETIMAGE;IMAGE_BITMAP;eax
;********************************************************************
; 设置是否“总在最前面”
;********************************************************************
。elseifax IDC_ONTOP
invoke IsDlgButtonChecked;hWnd;IDC_ONTOP
。if eax BST_CHECKED
invoke SetWindowPos;hWnd;HWND_TOPMOST;0;0;0;0;
SWP_NOMOVE or SWP_NOSIZE
。else
invoke SetWindowPos;hWnd;HWND_NOTOPMOST;0;0;0;0;
SWP_NOMOVE or SWP_NOSIZE
。endif
;********************************************************************
; 演示隐藏和显示图片控件
;********************************************************************
。elseifax IDC_SHOWBMP
invoke GetDlgItem;hWnd;IDC_BMP
mov ebx;eax
invoke IsWindowVisible;ebx
。if eax
invoke ShowWindow;ebx;SW_HIDE
。else
invoke ShowWindow;ebx;SW_SHOW
。endif
;********************************************************************
; 演示允许和灰化“更换图片”按钮
;********************************************************************
。elseifax IDC_ALOW
invoke IsDlgButtonChecked;hWnd;IDC_ALOW
。if eax BST_CHECKED
mov ebx;TRUE
。else
xor ebx;ebx
。endif
invoke GetDlgItem;hWnd;IDOK
invoke EnableWindow;eax;ebx
;********************************************************************
。elseifax IDC_MODALFRAME
invoke GetWindowLong;hWnd;GWL_STYLE
and eax;not WS_THICKFRAME
invoke SetWindowLong;hWnd;GWL_STYLE;eax
。elseifax IDC_THICKFRAME
invoke GetWindowLong;hWnd;GWL_STYLE
or eax;WS_THICKFRAME
invoke SetWindowLong;hWnd;GWL_STYLE;eax
;********************************************************************
; 演示处理下拉式组合框
;********************************************************************
。elseif ax IDC_TITLETEXT
shr eax;16
;********************************************************************
来源:电子工业出版社 作者:罗云彬 上一页 回书目 下一页
上一页 回书目 下一页
第5章 使用资源
5。4 对 话 框(6)
。if ax CBN_SELENDOK
invoke SendDlgItemMessage;hWnd;
IDC_TITLETEXT;CB_GETCURSEL;0;0
。if eax 2
invoke GetDlgItem;hWnd;IDC_CUSTOMTEXT
invoke EnableWindow;eax;TRUE 。else
mov ebx;eax
invoke SendDlgItemMessage;hWnd;IDC_TITLETEXT;
CB_GETLBTEXT;ebx;addr @szBuffer
invoke SetWindowText;hWnd;addr @szBuffer
invoke GetDlgItem;hWnd;IDC_CUSTOMTEXT
invoke EnableWindow;eax;FALSE
。endif
。endif
;********************************************************************
; 在文本框中输入文字
;********************************************************************
。elseifax IDC_CUSTOMTEXT
invoke GetDlgItemText;hWnd;IDC_CUSTOMTEXT;
addr @szBuffer;sizeof @szBuffer
invoke SetWindowText;hWnd;addr @szBuffer
。endif
;**************************************