0
votes

With Visual Studio 2010 came the inclusion of dockable windows in MDI and SDI applications for MFC projects. Yay! However, I'm having a problem with sizing a CFormView to fit the available area in the CFrame.

I have an SDI application which dynamically creates a view type the user chooses and sets it into the CFrame object.

I realize I could use MDI instead, but want to stay away from that because of the higher complexity of having multiple documents.

Creating the new view and showing it works well, but if i:

CView* pOldActiveView = GetActiveView();
CView* pNewActiveView = (CView*)new CMyView;
CRect r;
pOldActiveView->GetWindowRect(&r);
pNewActiveView->Create(NULL, NULL, 0, w, this, nForm, &context); 
pNewActiveView->OnInitialUpdate();

:then each time I open a new view the window moves up 8 pixels. I tried adjusting the CRect and that worked to fix that.

However, when I hide/dock the Output and Class windows, or even the Status Bar in the SDI Ribbon based application the CFormView does not resize automatically, and I can't find a way to find the CRect that I should resize it to. How can I get the CRect from the CFrame that the CFormView sits in?

1

1 Answers

0
votes

Nevermind. Upon no responses I decided to go another route. Instead of dynamically switching the view in the mainframe, i found this link, and added views to the document and switched them at will with no problems (mfc handled resizing) http://msdn.microsoft.com/en-us/library/s199bks0(v=vs.80).aspx