Here is a window that is resizable:
The dynamic layout properties are set so that the top group box resizes in width and the lower group/box and tree resize in both dimensions along with the 3 buttons.
For the advanced check box I added code to hide the extra controls and adjust the heights of the associated boxes. So it looks like this:
The code that is used to toggle the control values are:
void CWishListDlg::ToggleAdvancedMode()
{
CRect rtSortTalk, rtTalkSettings, rtTreeGroup, rtTree, rtTalkCombo;
m_staticSortTalk.ShowWindow(m_bAdvancedMode ? SW_SHOW : SW_HIDE);
m_cbTalkSortField.ShowWindow(m_bAdvancedMode ? SW_SHOW : SW_HIDE);
m_cbTalkSortOrder.ShowWindow(m_bAdvancedMode ? SW_SHOW : SW_HIDE);
m_staticSortSpeaker.ShowWindow(m_bAdvancedMode ? SW_SHOW : SW_HIDE);
m_cbSpeakerSortField.ShowWindow(m_bAdvancedMode ? SW_SHOW : SW_HIDE);
m_cbSpeakerSortOrder.ShowWindow(m_bAdvancedMode ? SW_SHOW : SW_HIDE);
m_staticTalkHistory.ShowWindow(m_bAdvancedMode ? SW_SHOW : SW_HIDE);
m_checkIncludeTalkHistory.ShowWindow(m_bAdvancedMode ? SW_SHOW : SW_HIDE);
m_staticStyle.ShowWindow(m_bAdvancedMode ? SW_SHOW : SW_HIDE);
m_cbStyle.ShowWindow(m_bAdvancedMode ? SW_SHOW : SW_HIDE);
m_staticSortTalk.GetWindowRect(&rtSortTalk);
m_staticSettings.GetWindowRect(&rtTalkSettings);
m_staticTreeDetails.GetWindowRect(&rtTreeGroup);
m_Tree.GetWindowRect(&rtTree);
if (m_bAdvancedMode)
{
rtTalkSettings.bottom += m_iOffsetY;
rtTreeGroup.top += m_iOffsetY;
rtTree.top += m_iOffsetY;
}
else
{
rtTalkSettings.bottom -= m_iOffsetY;
rtTreeGroup.top -= m_iOffsetY;
rtTree.top -= m_iOffsetY;
}
ScreenToClient(&rtTalkSettings);
ScreenToClient(&rtTreeGroup);
ScreenToClient(&rtTree);
m_staticSettings.MoveWindow(&rtTalkSettings);
m_staticTreeDetails.MoveWindow(&rtTreeGroup);
m_Tree.MoveWindow(&rtTree);
}
It works fine. I can toggle to my hearts content. Until I try to resize the window:
I can't see any way to recalculate the dynamic layout properties based on the active display.
If "Advanced" is ticked, so that the controls are visible (thus matching the resource editor) then it resizes fine. It is only when it is unticked and I have modified two of the controls that resizing won't work right.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…