Discussion:
Switching to an existing view
(too old to reply)
R.Krishnan
2006-04-26 18:22:25 UTC
Permalink
Hi:
I have a MDI document with multiple views. Before creating a new view of a
particular type, I would like to check if the view has already been created,
and if so switch to that view instead of creating a new version. This is
important since the user may have already reset some of the fields in the
existing view, and creating a new view may result in overwriting user
entries. Please bear with me as I am new to this, and searching the group
did not bring up anything enlightening.
Ajay Kalra
2006-04-26 19:33:08 UTC
Permalink
You should enumerate the views on the document and check if that
particular view is present. If its not present, you can call
CreateNewFrame on the doctemplate.

To enumerate views on a document, look at GetFirstViewPosition and
GetNextView.


---
Ajay
R.Krishnan
2006-04-26 20:21:18 UTC
Permalink
Post by Ajay Kalra
You should enumerate the views on the document and check if that
particular view is present. If its not present, you can call
CreateNewFrame on the doctemplate.
My reply didn't come through for some reason. I am doing this already in
the CMainFrm - I don't allow a new view of the same class be created. My
problem is, how do I switch to the view if it exists?
Ajay Kalra
2006-04-27 05:18:30 UTC
Permalink
Post by R.Krishnan
My reply didn't come through for some reason. I am doing this already in
the CMainFrm - I don't allow a new view of the same class be created. My
problem is, how do I switch to the view if it exists?
I think CMDIChildWnd::MDIActivate is what you are looking for. You can get
to CMDIChildWnd by using GetParentFrame on the view.

--
Ajay Kalra [MVP - VC++]
***@yahoo.com

Loading...