Originally posted by: roddy.muir
Although it is obvious to some guru's (unlike me!), in order for this call to work, in this case a CFormView, which is being displayed has to have the style changed, using the resource editor if you wish, from "popup", to "Child", otherwise the pNewActiveView->Create call asserts.
Richard and Uday thanks a lot! Just a minor quirk, which I found will ASSERT.
++R
Originally posted by: Colin Vella
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?
Your advice would be much appreciated!!
Regards,
Colin
Originally posted by: Uday Shastri
m_CurrentViewID = nForm;
//** End of Uday code
::SetWindowWord(pNewActiveView->m_hWnd, GWL_ID, AFX_IDW_PANE_FIRST); // gotta have it
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
//public:
// UINT m_CurrentViewID; // public variable required to be added
pOldActiveView->SetDlgCtrlID(m_CurrentViewID);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
RecalcLayout();
Uday Shastri
Originally posted by: Mason
Does anyone know what would be the fix for it?? I need to find this solution real bad..
Plz help.
ReplyOriginally posted by: jung soo
I fixed my program buf by your code.
I thank you for your openness.
so long.
ReplyOriginally posted by: XB
CView is All Right!
but Adding CFormView will ERROR!
in WIN2K!
Reply
Originally posted by: K
Hi.
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.
Originally posted by: Fady
Now the following statement:
CView* pNewActiveView = ( CView* )GetDlgItem( View_ID )
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
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.
Thank you for your time, have a good one
Please correct me when i'm wrong, i'm new to MFC, and i would like to understand and absorb everything.
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"
Originally posted by: Neil
I am trying to write an SDI application that works with one document but contains multiple frames. Each frame will have its own unique view.
Essentially, what I need is a version of your ScreenSwitch, that opens seperate windows (frames) for each of the different views
Think Photoshop in an SDI environment and you will begin to understand what I am trying to accomplish.
Originally posted by: JD
I would like to know if I'm missing something simple.
pNewActiveView = (CView*) GetDlgItem(nForm) always
returns NULL
if you don't call
delete pOldActiveView; // kill old view
you end up with a bunch of instances of the class. However, I don't want to create a new intance every time I switch views.
Why does GetDlgItem() always return NULL? Is the reason for the delete pOldaActiveView really a hack for the failure of GetDlgItem() to work?
Thank you so much
Reply