Resizing Controls in MFC

前端 未结 8 1983
萌比男神i
萌比男神i 2021-01-11 10:26

I am writing a program which has two panes (via CSplitter), however I am having problems figuring out out to resize the controls in each frame. For simplicity,

8条回答
  •  天命终不由人
    2021-01-11 10:34

    A window receives WM_SIZE message (which is processed by OnSize handler in MFC) immediately after it was resized, so CEdit::OnSize is not what you are looking for.

    You should add OnSize handler in your frame class and inside this handler as Rob pointed out you'll get width and height of the client area of your frame, then you should add the code which adjusts size and position of your control.

    Something like this

    void MyFrame::OnSize(UINT nType, int w, int h)
    {
        // w and h parameters are new width and height of your frame
        // suppose you have member variable CEdit myEdit which you need to resize/move
        myEdit.MoveWindow(w/5, h/5, w/2, h/2);
    }
    

提交回复
热议问题