孙鑫MFC学习笔记7:对话框编程(上)

1.DoModal创建模态对话框

2.Create创建非模态对话框(需要用ShowWindow显示出来)

模态:对话框显示,程序会暂停,直到对话框关闭

非模态:对话框显示,程序继续执行

3.对于模态对话框,点击确定/取消对话框被销毁,而对于模态对话框,只是被隐藏

4.对于模态对话框,需要在自己的类中覆盖OnOK这个虚函数,在OnOK中调用DestroyWindow

5.GetWindowText获取窗口文本

6.GetDlgItem获取对话框控件指针

7.SetWindowText设置窗口文本

8.静态文本框(标签)不能接收通知消息,除非把notify复选上

9.GetDlgItemText获取控件文本

10.SetDlgItemText设置控件文本

11.GetDlgItemInt获取控件数字

12.SetDlgItemInt设置控件数字

13.UpdateData参数为TRUE,获取数据,参数为FALSE,设置数据

在类向导里添加关联成员变量

14.WM_GETTEXT消息获取控件文本

An application sends a WM_GETTEXT message to copy the text that corresponds to a window into a buffer provided by the caller.

To send this message, call the SendMessage function with the following parameters.

SendMessage(

(HWND) hWnd,              // handle to destination window

WM_GETTEXT,               // message to send

(WPARAM) wParam,          // number of characters to copy

(LPARAM) lParam           // text buffer

);

15.WM_SETTEXT设置控件文本

wParam必须为0

16.SendDlgItemMessage向控件发送消息

17.EM_SETSEL

EM_SETSEL

The EM_SETSEL message selects a range of characters in an edit control. You can send this message to either an edit control or a rich edit control.

To send this message, call the SendMessage function with the following parameters.

SendMessage(

(HWND) hWnd,              // handle to destination window

EM_SETSEL,                // message to send

(WPARAM) wParam,          // starting position

(LPARAM) lParam          // ending position

);

18.EM_GETSEL

EM_GETSEL

The EM_GETSEL message retrieves the starting and ending character positions of the current selection in an edit control. You can send this message to either an edit control or a rich edit control.

To send this message, call the SendMessage function with the following parameters.

SendMessage(

(HWND) hWnd,              // handle to destination window

EM_GETSEL,                // message to send

(WPARAM) wParam,          // starting position (LPDWORD)

(LPARAM) lParam          // ending position (LPDWORD)

);

19.SetFocus设置焦点

20.GetFocus  获取焦点所在窗口

21.

孙鑫MFC学习笔记7:对话框编程(上)

22.IsRectEmpty判断矩形区域面积是否为0

23IsRectNull判断矩形区域四个参数是否都为0

24.

孙鑫MFC学习笔记7:对话框编程(上)

25.

孙鑫MFC学习笔记7:对话框编程(上)

26.

孙鑫MFC学习笔记7:对话框编程(上)

27.SetWindowPos可以改变窗口大小、z-order等状态

28.SetWindowLong设置窗口属性

29.WM_INITDIALOG在对话框创建前产生

30.GetNextWindow获取下一个窗口句柄

31.GetWindow获取窗口句柄

32.GetNextDlgTabItem获取下一个tab窗口

33.IDOK是OK按钮的缺省消息ID,不是IDC_OK

孙鑫MFC学习笔记7:对话框编程(上) 用菊子曰博客,就是爽!
上一篇:Matlab与.NET基于类型安全的接口混合编程入门


下一篇:孙鑫MFC学习笔记13:文档