需要一个图相框作为一个分隔条,把图相框设置为不可见
void CFstDlg::OnBnClickedBtnZoom() { CString cs; //用于保存控件的Caption if (GetDlgItemText(IDC_BTN_ZOOM, cs), cs == "收缩<<") { SetDlgItemText(IDC_BTN_ZOOM, L"扩展>>"); } else { SetDlgItemText(IDC_BTN_ZOOM, L"收缩<<"); } static CRect recLarge; static CRect recSmall; if (recLarge.IsRectNull()) //4值都为0适用用 它跟IsEmpty不同 { CRect recSeparator; //保存图相框的位置 GetWindowRect(&recLarge); //获取窗口初始大小 GetDlgItem(ID_SEPARATOR)->GetWindowRect(&recSeparator); recSmall.left = recLarge.left; recSmall.right = recLarge.right; recSmall.top = recLarge.top; recSmall.bottom = recSeparator.bottom; } if (cs == "收缩<<") { SetWindowPos(nullptr, 0, 0, recSmall.Width(), recSmall.Height(), SWP_NOMOVE | SWP_NOZORDER); //不移动,不改变Z次序 } else { SetWindowPos(nullptr, 0, 0, recLarge.Width(), recLarge.Height(), SWP_NOMOVE | SWP_NOZORDER); //不移动,不改变Z次序 } }