mfc编程 孙鑫_孙鑫MFC学习笔记7:对话框编程(上)
1.DoModal創(chuàng)建模態(tài)對話框
2.Create創(chuàng)建非模態(tài)對話框(需要用ShowWindow顯示出來)
模態(tài):對話框顯示,程序會暫停,直到對話框關(guān)閉
非模態(tài):對話框顯示,程序繼續(xù)執(zhí)行
3.對于模態(tài)對話框,點擊確定/取消對話框被銷毀,而對于模態(tài)對話框,只是被隱藏
4.對于模態(tài)對話框,需要在自己的類中覆蓋OnOK這個虛函數(shù),在OnOK中調(diào)用DestroyWindow
5.GetWindowText獲取窗口文本
6.GetDlgItem獲取對話框控件指針
7.SetWindowText設(shè)置窗口文本
8.靜態(tài)文本框(標(biāo)簽)不能接收通知消息,除非把notify復(fù)選上
9.GetDlgItemText獲取控件文本
10.SetDlgItemText設(shè)置控件文本
11.GetDlgItemInt獲取控件數(shù)字
12.SetDlgItemInt設(shè)置控件數(shù)字
13.UpdateData參數(shù)為TRUE,獲取數(shù)據(jù),參數(shù)為FALSE,設(shè)置數(shù)據(jù)
在類向?qū)Ю锾砑雨P(guān)聯(lián)成員變量
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設(shè)置控件文本
wParam必須為0
16.SendDlgItemMessage向控件發(fā)送消息
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設(shè)置焦點
20.GetFocus 獲取焦點所在窗口
21.
22.IsRectEmpty判斷矩形區(qū)域面積是否為0
23IsRectNull判斷矩形區(qū)域四個參數(shù)是否都為0
24.
25.
26.
27.SetWindowPos可以改變窗口大小、z-order等狀態(tài)
28.SetWindowLong設(shè)置窗口屬性
29.WM_INITDIALOG在對話框創(chuàng)建前產(chǎn)生
30.GetNextWindow獲取下一個窗口句柄
31.GetWindow獲取窗口句柄
32.GetNextDlgTabItem獲取下一個tab窗口
33.IDOK是OK按鈕的缺省消息ID,不是IDC_OK
?用菊子曰寫博客,就是爽!
總結(jié)
以上是生活随笔為你收集整理的mfc编程 孙鑫_孙鑫MFC学习笔记7:对话框编程(上)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android ftp 客户端编写(ft
- 下一篇: 孙鑫VC++深入详解第一章学习笔记