0

I am new to MFC and I am trying to change the size of my objects with respect to form. For this, I am using single document project and in View.cpp and MainFrm.cpp I have changed form size.

  BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    if( !CFrameWnd::PreCreateWindow(cs) )
        return FALSE;
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs
    cs.cx = 400;
    cs.cy = 400;
    return TRUE;
}

and in View.cpp, I have fixed the initial size of screen as given below.

BOOL CDCDrawingView::PreCreateWindow(CREATESTRUCT& cs)
{
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs
    cs.cx = 400;
    //const wchar_t a = cs.cx;
    width = cs.cx;
    cs.cy = 400;
     height = cs.cy;
    return CView::PreCreateWindow(cs);
}

Here comes the problem, I want to draw the objects and I want to change the size of those objects with respect to size of form by using mouse. The form is able to change its size but I dont know how to update the form coordinates. I have attached the initial form and and form after changing size by mouse. initial form is given below. enter image description here and form after changing size by mouse is given below. enter image description here could someone please tell me how to change the objects with resizing form? Thanks in advance.

ali
  • 13
  • 3
  • To solve this problem, get main window size by using //Get main window size CRect rect; GetClientRect(&rect); – ali Mar 31 '20 at 05:43
  • @IInspectable, it is not the same post anyway, and here is the answer I added in comments. – ali Mar 31 '20 at 05:51
  • It is a duplicate. And if you follow the answers you'll find that you do not need to call `GetClientRect`. Your [OnSize](https://learn.microsoft.com/en-us/cpp/mfc/reference/cwnd-class#onsize) handler already receives the parameters that reflect the new client area size. – IInspectable Mar 31 '20 at 08:01

0 Answers0