完善WTL的分割窗口之SubclassWindow
2008-01-28 08:54
357 查看
WTL的CSplitterWindow并没有提供SubclassWindow的功能,这样在对话框应用程序中不便于使用,我们为其增加一个SubclassWindow,这样在对话框窗口设计中就可以使用Static控件来代替分割窗口进行设计。
m_wndSplit.SubclassWindow(GetDlgItem(IDC_SPLIT));
......
以下是CSplitterWindow的SubclassWindow代码:
BOOL SubclassWindow(HWND hWnd)
{
ATLASSERT(m_hWnd == NULL);
ATLASSERT(::IsWindow(hWnd));
#if (_MSC_VER >= 1300)
BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits>::SubclassWindow(hWnd);
#else // !(_MSC_VER >= 1300)
typedef ATL::CWindowImpl< T, TBase, TWinTraits> _base;
BOOL bRet = _base::SubclassWindow(hWnd);
#endif // !(_MSC_VER >= 1300)
if (bRet)
{
const int cchBuff = 8;
TCHAR szBuffer[cchBuff] = { 0 };
if(::GetClassName(m_hWnd, szBuffer, cchBuff))
{
if(lstrcmpi(szBuffer, _T("static")) == 0)
{
ModifyStyle(0, SS_NOTIFY); // we need this
}
}
GetSystemSettings(false);
SetSplitterRect();
}
return bRet;
}
m_wndSplit.SubclassWindow(GetDlgItem(IDC_SPLIT));
......
以下是CSplitterWindow的SubclassWindow代码:
BOOL SubclassWindow(HWND hWnd)
{
ATLASSERT(m_hWnd == NULL);
ATLASSERT(::IsWindow(hWnd));
#if (_MSC_VER >= 1300)
BOOL bRet = ATL::CWindowImpl< T, TBase, TWinTraits>::SubclassWindow(hWnd);
#else // !(_MSC_VER >= 1300)
typedef ATL::CWindowImpl< T, TBase, TWinTraits> _base;
BOOL bRet = _base::SubclassWindow(hWnd);
#endif // !(_MSC_VER >= 1300)
if (bRet)
{
const int cchBuff = 8;
TCHAR szBuffer[cchBuff] = { 0 };
if(::GetClassName(m_hWnd, szBuffer, cchBuff))
{
if(lstrcmpi(szBuffer, _T("static")) == 0)
{
ModifyStyle(0, SS_NOTIFY); // we need this
}
}
GetSystemSettings(false);
SetSplitterRect();
}
return bRet;
}
相关文章推荐
- 窗口子类化三:SubClassWindow详解
- SubClassWindow--------实现窗口子类化的函数
- CWnd中PreCreateWindow、PreSubclassWindow、SubclassWindow的区别
- Custom Splitter Window 对话框上实现窗口分割
- How To Subclass a Window in Windows 95
- SubClassWindow用法
- 有关SubClassWindow的用法
- (转)走出MFC子类化的迷宫:子类化,SUBCLASSWINDOW ,MFC消息机制 ---(摘自CSDN论坛)
- SubClassWindow详解
- CWnd中PreCreateWindow、PreSubclassWindow、SubclassWindow的区别
- VS2005 实现单文档中的窗口分割(SDI with split window)
- 如何子类化(SubclassWindow)窗体 .
- 如何子类化(SubclassWindow)窗体
- SubClassWindow详解
- SubclassWindow
- (转)走出MFC子类化的迷宫:子类化,SUBCLASSWINDOW ,MFC消息机制 ---(摘自CSDN论坛)
- WTL分割窗口
- (转)走出MFC子类化的迷宫:子类化,SUBCLASSWINDOW ,MFC消息机制
- 转载 SubClassWindow 详解
- winform错误提示 :窗口类名无效(Window class name is not valid)