SubclassWindow和SubclassDlgItem
来源:互联网 发布:淘宝开店阿里巴巴专栏 编辑:程序博客网 时间:2024/05/24 01:41
问题缘起
通常如果在对话框中将一个控件映射到一个变量,有三种方法:
1.
2.
3.
例如CEdit m_edit; m_edit.SubclassDlgItem(IDC_EDIT1);
SubclassWindow
AfxGetAfxWndProc返回了AfxWndProc的函数指针,即窗口函数的指针,AfxWndProc包裹了AfxCallWndProc,后者又调用了pWnd->WindowProc(nMsg, wParam, lParam);。
可见SubclassWindow完成了两项功能:
1.
2.
SubclassDlgItem
GetDlgItem
SubclassDlgItem和GetDlgItem二者的区别
HWND hWndControl = ::GetDlgItem(pParent->m_hWnd, IDC_EDIT1);
m_edit.SubclassWindow (hWndControl);
参考资料(MSDN):
This member function attaches the Windows control to a CWnd object and replaces the window’sWndProc and AfxWndProc functions. The function stores a pointer to the old WndProc in the CWndobject.
参考资料(来自CSDN)
http://dev.csdn.net/Develop/article/16/16045.shtm
参考资料(来自Programming Windows)
The window procedure for the scroll bar controls is somewhere inside Windows. However, you can obtain the address of this window procedure by a call to GetWindowLong using the GWL_WNDPROC identifier as a parameter. Moreover, you can set a new window procedure for the scroll bars by calling SetWindowLong. This technique, which is called "window subclassing," is very powerful. It lets you hook into existing window procedures, process some messages within your own program, and pass all other messages to the old window procedure.
The window procedure that does preliminary scroll bar message processing in COLORS1 is namedScrollProc; it is toward the end of the COLORS1.C listing. Because ScrollProc is a function within COLORS1 that is called by Windows, it must be defined as a CALLBACK.
For each of the three scroll bars, COLORS1 uses SetWindowLong to set the address of the new scroll bar window procedure and also obtain the address of the existing scroll bar window procedure:
OldScroll[i] = (WNDPROC) SetWindowLong (hwndScroll[i], GWL_WNDPROC,
Now the function ScrollProc gets all messages that Windows sends to the scroll bar window procedure for the three scroll bars in COLORS1 (but not, of course, for scroll bars in other programs). The ScrollProc window procedure simply changes the input focus to the next (or previous) scroll bar when it receives a Tab or Shift-Tab keystroke. It calls the old scroll bar window procedure using CallWindowProc.
http://www.newsmth.net/pc/pccon.php?id=1363&nid=81054
- SubclassWindow和SubclassDlgItem
- SubclassWindow和SubclassDlgItem介绍
- SubclassWindow和SubclassDlgItem
- 【C++】DDX_Control、SubclassWindow和SubclassDlgItem的区别
- Subclassdlgitem
- CWnd::SubclassWindow和::SetWindowLong
- SubclassWindow
- 3月25日 subclassdlgitem、release和debug、ondlgctrlid
- 利用SubclassDlgItem函数动态连接控件和控件对象
- 利用SubclassDlgItem函数动态连接控件和控件对象
- 关于SubClassDlgItem
- 关于SubClassDlgItem
- SUBCLASSDLGITEM函数
- SUBCLASSDLGITEM函数
- CWnd::SubclassWindow
- SubClassWindow详解
- SubclassWindow 说明
- SubClassWindow详解
- Python风格规范
- WeChall mysql WriteUp
- jQuery修改操作css属性实现方法
- matlab二值图像腐蚀(黑白图像)
- Unity3D Resources TextAsset 文本
- SubclassWindow和SubclassDlgItem
- 老杨聊架构:每个架构师都应该研究下康威定律
- 将node.js移植到arm开发板
- 如何在Ubuntu 14.04中安装最新版Eclipse
- 走迷宫2
- Xcode重构功能怎么用我全告诉你
- iOS9 视图弹出的弹簧效果
- nginx常用超时设置
- Android Audio System之二:AudioFlinger