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;
}