mfcsdi

Center a CFormView "dialog resource" within the CMainFrame window in a SDI


I have a dialog resource with some controls inside, mostly a user and password edit controls, bonded to a CFormView. Such dialog is a small rectangle of 300 x 200 pixels.

When I run the application, the CFrameWindow occupies almost all screen, so the dialog shows in top-left corner. If I try to get the rectangle dimension of CFormView, I found that it has been expanded to visible area in CMainFrame, no matter the original dialog size.

What I currently get

My question is whether is possible to keep the dialog (the CFormView) centred in the middle of the CMainFrame, and keep always centred even if the ON_SIZE message is called.

What I want

Thank you.


Solution

  • In VS2019 you don't have to write any line of code. The rc Editor has the dynamic layout function capabilities. Place the controls exactly in the middle of the dialog. Then set the

    enter image description here