When i create Cdockablepane on the MFC, the pane size is not restored to its previous state on run.

민호 송 0 Reputation points
2023-02-18T02:11:37.1033333+00:00

Hello, I am making software using the Cdockablepane of MFC.

But there's one problem.

If the Cdockablepane attached to the Mainfrm is more than 1780 pixels horizontally, the size returns to 1780 when it is shut down and restarted.

Strangely, the Cdockablepane floating outside MainFrm returns to its original size when it restarts, even if the horizontal size is larger than 1780 pixels.

Please help me with my poor skills.

please, refer to below captured pictures.

[Before shutdown]

before_shutdown

[After restarted]

User's image

Developer technologies | C++
Developer technologies | Visual Studio | Other
{count} votes

1 answer

Sort by: Most helpful
  1. 민호 송 0 Reputation points
    2023-02-20T00:50:10.5433333+00:00

    I solved it.

    When I added the cs.cy and cs.cx codes as below, the change due to the size limitation disappeared when I restarted.

    Thank you.

    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
    {
       if(!Cls_DrMfcDockMainFrm::PreCreateWindow(cs))
          return FALSE;
       // TODO: Modify the Window class or styles here by modifying
       //  the CREATESTRUCT cs
       cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
       cs.lpszClass = AfxRegisterWndClass(0);
       cs.cx = GetSystemMetrics(SM_CXSCREEN);
       cs.cy = GetSystemMetrics(SM_CYSCREEN);
       
       if (cs.hMenu != NULL)
       {
          ::DestroyMenu(cs.hMenu);
          cs.hMenu = NULL;
       }
    }
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.