MFC_MoveWindow窗口、控件的大小、位置調整

同一個資源文件,在不一樣的地方顯示不一樣,好比:code

只須要把第一個界面,隱藏【數據提交詳情】部分,按鈕移動到合適位置,對話框調整大小就能夠獲得第二個對話框。資源

具體代碼:class

//得到按鈕移動的高度
CRect rectStatic;
GetDlgItem(IDC_STATIC_RESULT)->GetWindowRect(rectStatic);
int nVal = rectStatic.Height();

//移動按鈕
CRect rectBtn;
CWnd* wndMove = GetDlgItem(IDOK);
wndMove->GetWindowRect(rect);

ScreenToClient(rect);
if (rect.top > nTop)
    rect.top = rect.top - nTop;

if (rect.bottom > nBottom)
    rect.bottom = rect.bottom - nBottom;

wndMove->MoveWindow(rect);

//移動窗口
CRect rectDlg;// 對話框域
GetWindowRect(rectDlg);

CRect recWindow;
HWND hwnd = ::GetDesktopWindow();
::GetWindowRect(hwnd,recWindow);

CRect rectBtn;// 定位按鈕域
GetDlgItem(IDC_BTN_LOCATION)->GetWindowRect(rectBtn);

if (rectDlg.bottom < rectBtn.bottom)
     return;

rectDlg.bottom = rectBtn.top + rectBtn.Height() + 10;

MoveWindow(rectDlg);
相關文章
相關標籤/搜索