Multiple Interchangeable Views (MFC/C++)
I have a main frame with a splitter. On the left I have my (imaginatively named) CAppView_Leftand on the right I have CAppView_Right_1and CAppView_Right_2. Through the following code I initialise the two primary views correctly:
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to CreateStaticSplitter\n");
return FALSE;
}
else
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CAppView_Left), CSize(300, 200), pContext))
{
TRACE0("Failed to create left pane\n");
return FALSE;
}
else
if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CAppView_Right_1), CSize(375, 200), pContext))
{
TRACE0("Failed to create first right pane\n");
return FALSE;
}
...
What I would like to do is create a second view inside the right frame, however when I try to add this:
if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CAppView_Right_2), CSize(375, 200), pContext))
{
TRACE0("Failed to create first right pane\n");
return FALSE;
}
VS compiles but fails to run the application, raising an exception telling me I have already defined the view.
Can someone suggest how I do this? Also, how to change between the views from either a view or the document class?
Answer
There is a CodeProject article that should help you achieve what you want:
http://www.codeproject.com/KB/splitter/usefulsplitter.aspx
I have replaced views in a splitter before, so if the above doesn't help I'll post some of my own code.
Related Questions
- → Comparing two large files are taking over four hours
- → Setting JSON node name to variable value
- → Compiling GLUT using Emscripten
- → Evaluate check box from a scanned image in node.js
- → Find an easy web server framework for mobile game
- → my https C++ code doesn't work on some sites (binance)
- → Error while opening pivx wallet on ubuntu
- → Why sending a POST by AJAX is interpreted by the HTTP Server as OPTIONS and sending by CURL is effectively a PUT?
- → Python reading in one line multiple types for a calculator
- → How do I properly pass an argument to a function
- → Accessing Websql database with Qt
- → Using Mysql C API for c++ codes
- → How do I set constants at run-time in a c++ header file, imported through Cython?