mfc编程 孙鑫_孙鑫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.
22.IsRectEmpty判斷矩形區域面積是否為0
23IsRectNull判斷矩形區域四個參數是否都為0
24.
25.
26.
27.SetWindowPos可以改變窗口大小、z-order等狀態
28.SetWindowLong設置窗口屬性
29.WM_INITDIALOG在對話框創建前產生
30.GetNextWindow獲取下一個窗口句柄
31.GetWindow獲取窗口句柄
32.GetNextDlgTabItem獲取下一個tab窗口
33.IDOK是OK按鈕的缺省消息ID,不是IDC_OK
?用菊子曰寫博客,就是爽!
總結
以上是生活随笔為你收集整理的mfc编程 孙鑫_孙鑫MFC学习笔记7:对话框编程(上)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android ftp 客户端编写(ft
- 下一篇: 孙鑫VC++深入详解第一章学习笔记