我在上个月写了完善WTL的分隔窗口控制一文,这篇文章为该文的补充及完善。
在完善WTL的分隔窗口控制一文中我们通过修改WTL的CSplitterWindow实现了如下变更,即分隔窗口的两个子面板窗口可以为对话框窗口中的控件,不需要将这两个控件的父窗口设置为分隔窗口。但是我们发现如果使用CPaneContainer控件或子对话框窗口作为子面板,则CPaneContainer或对话框窗口仍然必须设置父窗口为分隔窗口。我们通过修改分隔窗口的代码来完善这一点,修改后CPaneContainer控件或子对话框窗口的父窗口为分隔窗口所在对话框窗口的子窗口即可。代码如下:
void
UpdateSplitterLayout()
... {
if(m_nSinglePane == SPLIT_PANE_NONE && m_xySplitterPos == -1)
return;
T* pT = static_cast<T*>(this);
RECT rect = ...{ 0, 0, 0, 0 };
if(m_nSinglePane == SPLIT_PANE_NONE)
...{
if(GetSplitterBarRect(&rect))
pT->InvalidateRect(&rect);
for(int nPane = 0; nPane < m_nPanesCount; nPane++)
...{
if(GetSplitterPaneRect(nPane, &rect))
...{
if(m_hWndPane[nPane] != NULL)
...{
DWORD dwFlag = SWP_NOZORDER;
HWND hWndParent = ::GetParent(m_hWndPane[nPane]);
if (hWndParent != pT->m_hWnd)
...{
dwFlag = 0;
pT->ClientToScreen(&rect);
CWindow(hWndParent).ScreenToClient(&rect);
}
::SetWindowPos(m_hWndPane[nPane], NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, dwFlag);
}
else
pT->InvalidateRect(&rect);
}
}
}
else
...{
if(GetSplitterPaneRect(m_nSinglePane, &rect))
...{
if(m_hWndPane[m_nSinglePane] != NULL)
...{
DWORD dwFlag = SWP_NOZORDER;
HWND hWndParent = ::GetParent(m_hWndPane[m_nSinglePane]);
if (hWndParent != pT->m_hWnd)
...{
dwFlag = 0;
pT->ClientToScreen(&rect);
CWindow(hWndParent).ScreenToClient(&rect);
}
::SetWindowPos(m_hWndPane[m_nSinglePane], NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, dwFlag);
}
else
pT->InvalidateRect(&rect);
}
}
}
... {
if(m_nSinglePane == SPLIT_PANE_NONE && m_xySplitterPos == -1)
return;
T* pT = static_cast<T*>(this);
RECT rect = ...{ 0, 0, 0, 0 };
if(m_nSinglePane == SPLIT_PANE_NONE)
...{
if(GetSplitterBarRect(&rect))
pT->InvalidateRect(&rect);
for(int nPane = 0; nPane < m_nPanesCount; nPane++)
...{
if(GetSplitterPaneRect(nPane, &rect))
...{
if(m_hWndPane[nPane] != NULL)
...{
DWORD dwFlag = SWP_NOZORDER;
HWND hWndParent = ::GetParent(m_hWndPane[nPane]);
if (hWndParent != pT->m_hWnd)
...{
dwFlag = 0;
pT->ClientToScreen(&rect);
CWindow(hWndParent).ScreenToClient(&rect);
}
::SetWindowPos(m_hWndPane[nPane], NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, dwFlag);
}
else
pT->InvalidateRect(&rect);
}
}
}
else
...{
if(GetSplitterPaneRect(m_nSinglePane, &rect))
...{
if(m_hWndPane[m_nSinglePane] != NULL)
...{
DWORD dwFlag = SWP_NOZORDER;
HWND hWndParent = ::GetParent(m_hWndPane[m_nSinglePane]);
if (hWndParent != pT->m_hWnd)
...{
dwFlag = 0;
pT->ClientToScreen(&rect);
CWindow(hWndParent).ScreenToClient(&rect);
}
::SetWindowPos(m_hWndPane[m_nSinglePane], NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, dwFlag);
}
else
pT->InvalidateRect(&rect);
}
}
}