Great piece of code.. I have just one question however.. can this system be used to switch to a view with a nested splitter?
I'm asking this as the only way I've found (so far) to nest splitters is to use a CSplitterWnd directly within another CSplitterWnd or a main frame (CFrameWnd). This of course, doesn't work with view-switching code described here.
Is it possible to use CSplitterWnd within a view (CView derived class)? If not, what are the alternatives? Is there a splitter control?
There are three lines of coding and a variable required to make above source run.
SetActiveView(pNewActiveView); // change the active view
pNewActiveView->ShowWindow(SW_SHOW); // show the new window
pOldActiveView->ShowWindow(SW_HIDE); // hide the old
// ** Added by Uday
// UINT m_CurrentViewID; // public variable required to be added
The view switching article is great. I tried it out for a formview based app. But I am unable to print any view other than the main view. The WM_PRINT message is not fired when I press Ctrl P from any of the new views. How can I overcome this?
Thanks a lot.
so the getDlgItem returns a pointer to the currently active view of type CWnd, since a CView is a Derive class of the indirect base class CWnd, then base class can hold derive class pointer. assume that the current View is an object of CRecordView
now casting CView out of CWnd will return a pointer to CRecordView ( i guess ), now assuming that the pointer returned from GetDlgItem is zero, we have to construct a View which in our case is COrderView of type CRecordView, so we only say
pNewActiveView = new COrderView; we don't need the cast ( CView* ) cause a derive class is a base class ( this will invoke implicit cast ), "please feel free to correct me"
All right, the pNewActiveView->Create(), This function is inherited from CWnd, what i don't understand it calls Create for CFormView??? i don't get it? why CFormView?
Please i appreciate if anyone can help me with this, i feel really discourage and can't continue reading without understand this, i value your time, and i know how you guys busy, but also if you recommend me a web site, that has a good explanation of the above.