您的位置:首页 > 其它

完善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;
 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  null