c++ MFC筆記009 設置窗口大小,伸縮窗體
阿新 • • 發佈:2019-03-02
clas ptr 窗口 class ext tex std lse cse
需要一個圖相框作為一個分隔條,把圖相框設置為不可見
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次序 } }
c++ MFC筆記009 設置窗口大小,伸縮窗體