Two different views in a splitter window, one doc (SDI)
-
The summary of my problem is this: two different views in a splitter window, one doc (SDI). I want to access the document's members from both views. I've created an application with a CSplitterWnd in my MainFrame. I've created the two views using m_wndSplitter.CreateView(....); That displays fine. Wonderful. I've got a variable in my doc class, int lookie. It's public. My class names are as follows: CThingApp -> the app class CThingDoc -> the doc class CThingControlView -> the form view containing the controls CThingDisplayView -> the graphical view displaying the data CMainFrame -> frame class CThingControlView was created with the whole project. I added CThingDisplayView. So I changed the code in CThingApp:InitInstance() to look like this: //////////////////////////// CSingleDocTemplate* pDocControlTemplate; pDocControlTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingControlView)); AddDocTemplate(pDocControlTemplate); //////////////////////////// This seems to work. Here's where my confusion sets in. I *thought* I now need to add the following code immediately beneath the above code: //////////////////////////// CSingleDocTemplate* pDocDisplayTemplate; pDocDisplayTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingDisplayView)); AddDocTemplate(pDocDisplayTemplate); //////////////////////////// I now believe that to be a false assumption because, upon building, the application displays a funny little window with the title new and what appears to be a list of options. There are two options with exactly the same text (which appears to be shortenings of my project name). If I select either one the application then starts. Because this was incorrect behavior, I commented out the second document template code and tried several different ways of just *accessing* the data in CThingDoc from CThingDisplayView. Nothing's working. I'm sure there is a simple solution to this. Something that my examples neglect to tell me or that I'm just not noticing.
-
The summary of my problem is this: two different views in a splitter window, one doc (SDI). I want to access the document's members from both views. I've created an application with a CSplitterWnd in my MainFrame. I've created the two views using m_wndSplitter.CreateView(....); That displays fine. Wonderful. I've got a variable in my doc class, int lookie. It's public. My class names are as follows: CThingApp -> the app class CThingDoc -> the doc class CThingControlView -> the form view containing the controls CThingDisplayView -> the graphical view displaying the data CMainFrame -> frame class CThingControlView was created with the whole project. I added CThingDisplayView. So I changed the code in CThingApp:InitInstance() to look like this: //////////////////////////// CSingleDocTemplate* pDocControlTemplate; pDocControlTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingControlView)); AddDocTemplate(pDocControlTemplate); //////////////////////////// This seems to work. Here's where my confusion sets in. I *thought* I now need to add the following code immediately beneath the above code: //////////////////////////// CSingleDocTemplate* pDocDisplayTemplate; pDocDisplayTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingDisplayView)); AddDocTemplate(pDocDisplayTemplate); //////////////////////////// I now believe that to be a false assumption because, upon building, the application displays a funny little window with the title new and what appears to be a list of options. There are two options with exactly the same text (which appears to be shortenings of my project name). If I select either one the application then starts. Because this was incorrect behavior, I commented out the second document template code and tried several different ways of just *accessing* the data in CThingDoc from CThingDisplayView. Nothing's working. I'm sure there is a simple solution to this. Something that my examples neglect to tell me or that I'm just not noticing.
Here you have a goog tutuorial about the splinter window : http://www.codeproject.com/splitter/splitterwindowtutorial.asp[^] I do not think you need to recreate a template for the second view...
http://www.readytogiveup.com/[^] - Do something special today.
-
The summary of my problem is this: two different views in a splitter window, one doc (SDI). I want to access the document's members from both views. I've created an application with a CSplitterWnd in my MainFrame. I've created the two views using m_wndSplitter.CreateView(....); That displays fine. Wonderful. I've got a variable in my doc class, int lookie. It's public. My class names are as follows: CThingApp -> the app class CThingDoc -> the doc class CThingControlView -> the form view containing the controls CThingDisplayView -> the graphical view displaying the data CMainFrame -> frame class CThingControlView was created with the whole project. I added CThingDisplayView. So I changed the code in CThingApp:InitInstance() to look like this: //////////////////////////// CSingleDocTemplate* pDocControlTemplate; pDocControlTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingControlView)); AddDocTemplate(pDocControlTemplate); //////////////////////////// This seems to work. Here's where my confusion sets in. I *thought* I now need to add the following code immediately beneath the above code: //////////////////////////// CSingleDocTemplate* pDocDisplayTemplate; pDocDisplayTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingDisplayView)); AddDocTemplate(pDocDisplayTemplate); //////////////////////////// I now believe that to be a false assumption because, upon building, the application displays a funny little window with the title new and what appears to be a list of options. There are two options with exactly the same text (which appears to be shortenings of my project name). If I select either one the application then starts. Because this was incorrect behavior, I commented out the second document template code and tried several different ways of just *accessing* the data in CThingDoc from CThingDisplayView. Nothing's working. I'm sure there is a simple solution to this. Something that my examples neglect to tell me or that I'm just not noticing.
Stop fiddling around with the DocumentTemplate! You'll eventually destroy your application and need to start over! Create the splitter with its views a s described in the other post. Then, to access the document, you need to use
CThingDoc* pDoc = dynamic_cast(GetDocument());
if()
{
//do it
}in your CThingDisplayView and CThingControlView.
Failure is not an option - it's built right in.
{
-
The summary of my problem is this: two different views in a splitter window, one doc (SDI). I want to access the document's members from both views. I've created an application with a CSplitterWnd in my MainFrame. I've created the two views using m_wndSplitter.CreateView(....); That displays fine. Wonderful. I've got a variable in my doc class, int lookie. It's public. My class names are as follows: CThingApp -> the app class CThingDoc -> the doc class CThingControlView -> the form view containing the controls CThingDisplayView -> the graphical view displaying the data CMainFrame -> frame class CThingControlView was created with the whole project. I added CThingDisplayView. So I changed the code in CThingApp:InitInstance() to look like this: //////////////////////////// CSingleDocTemplate* pDocControlTemplate; pDocControlTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingControlView)); AddDocTemplate(pDocControlTemplate); //////////////////////////// This seems to work. Here's where my confusion sets in. I *thought* I now need to add the following code immediately beneath the above code: //////////////////////////// CSingleDocTemplate* pDocDisplayTemplate; pDocDisplayTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CThingDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CThingDisplayView)); AddDocTemplate(pDocDisplayTemplate); //////////////////////////// I now believe that to be a false assumption because, upon building, the application displays a funny little window with the title new and what appears to be a list of options. There are two options with exactly the same text (which appears to be shortenings of my project name). If I select either one the application then starts. Because this was incorrect behavior, I commented out the second document template code and tried several different ways of just *accessing* the data in CThingDoc from CThingDisplayView. Nothing's working. I'm sure there is a simple solution to this. Something that my examples neglect to tell me or that I'm just not noticing.
For splitter windows, you only need one
CSingleDocTemplate
object that is created like:CSingleDocTemplate* pDocControlTemplate;
pDocControlTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CThingDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(NULL));
AddDocTemplate(pDocControlTemplate);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne