Several views for one document in MDI?
-
On days like this I feel like a total n00b, even after three years of intensivly using MFC... do a good deed today and help me... pleeeease! I do have Visual Studio .NET 2003 and plan to make a multi document application with several different views for each document so I can switch on-the-fly between those different views with some buttons on the toolbar. For achieving this I used the project wizard to generate a multi document Doc/View application with the view derived from CView. So far so good. Now I inserted a new MFC class derived from CFormView and I enabled the checkbox "Create DocTemplate ressources". Afterwards I had a new class, a new dialog in the ressources and in the applications InitInstance() I got this:
CMultiDocTemplate* pNewDocTemplate = new CMultiDocTemplate(
IDR_SOMEFORMVIEW_TMPL,
RUNTIME_CLASS(CTestMultiViewsDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CSomeFormView));
AddDocTemplate(pNewDocTemplate);When I start my application now I get the following window: (image link) Question 1: how do I circumvent this dialog and preselect one of those views? Question 2: how do I switch between those views during runtime without closing/deleting the document? Jup, that would be it. I have already read this Codeproject article and this (quite old) Codeguru article but I do not get it working as I want it to work. There must be a good and simple solution for this, because my intend isn't that special I think. So please tell me how to do it or where to read more about it. Thanks & Bye, Matthias / T.T.H.
-
On days like this I feel like a total n00b, even after three years of intensivly using MFC... do a good deed today and help me... pleeeease! I do have Visual Studio .NET 2003 and plan to make a multi document application with several different views for each document so I can switch on-the-fly between those different views with some buttons on the toolbar. For achieving this I used the project wizard to generate a multi document Doc/View application with the view derived from CView. So far so good. Now I inserted a new MFC class derived from CFormView and I enabled the checkbox "Create DocTemplate ressources". Afterwards I had a new class, a new dialog in the ressources and in the applications InitInstance() I got this:
CMultiDocTemplate* pNewDocTemplate = new CMultiDocTemplate(
IDR_SOMEFORMVIEW_TMPL,
RUNTIME_CLASS(CTestMultiViewsDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CSomeFormView));
AddDocTemplate(pNewDocTemplate);When I start my application now I get the following window: (image link) Question 1: how do I circumvent this dialog and preselect one of those views? Question 2: how do I switch between those views during runtime without closing/deleting the document? Jup, that would be it. I have already read this Codeproject article and this (quite old) Codeguru article but I do not get it working as I want it to work. There must be a good and simple solution for this, because my intend isn't that special I think. So please tell me how to do it or where to read more about it. Thanks & Bye, Matthias / T.T.H.
losing the dialog in 1. involves changing the command line passed to the app in initinstance() ... cant remember exactly what but look in msdn and it'll be there 2. switching between views? u mean creating a new view or what exactly? the user switches between them with the mouse unless u mean a different representation of the same data ... in which case ur OnDraw() handler can do that for you :)
-
losing the dialog in 1. involves changing the command line passed to the app in initinstance() ... cant remember exactly what but look in msdn and it'll be there 2. switching between views? u mean creating a new view or what exactly? the user switches between them with the mouse unless u mean a different representation of the same data ... in which case ur OnDraw() handler can do that for you :)
Concerning 1: I solved the problem another way and don't have multiple document templates now - so I don't need to preselect one of them. Concerning 2: I want to switch through all the views by some buttons on the toolbar. I guess I developed a solution yesterday solving my problem. I appended a (quite long) post under Jorge's articel about switching views. You can find it here. Thanks for the help, Matthias / T.T.H.