Ashurbanipal
asked on
problem with splitter windowsI
When I normally build and run my application it uses mdi and splitter windows. However there are times when I want to build and run it and only have one view showing. My problem is that everything is set up to create a splitter window, but splitter windows won't work with a single row and single column. Is there an easy work around?
And you also can prevent user from "opening" empty part of splitter.
ASKER
Won't this still show an extra thick line on one side?
Is there any way to supress the splitter code completely depending on build settings?
Is there any way to supress the splitter code completely depending on build settings?
You said it's an MDI application, right? Create the view with the MDI template that doesn't contain the splitter window class.
The view you want to show is inside a splitter window, and has to be fully formed already into a template. Just create that template instance instead of the splitter window template instance.
Am I making any sense?
The view you want to show is inside a splitter window, and has to be fully formed already into a template. Just create that template instance instead of the splitter window template instance.
Am I making any sense?
ASKER
What you say makes sense in theory, it's applying it to the problem that's giving me grief.
In CMainFrame::OnCreateClient (LPCREATES TRUCT lpcs,
CCreateContext* pContext)
I did a test for the not splitter condition and then tried
pContext->m_pNewViewClass= RUNTIME_CL ASS(CPictu reView);
return CFrameWnd::OnCreateClient( lpcs,pCont ext);
but that doesn't work.
I've upped the points.
In CMainFrame::OnCreateClient
CCreateContext* pContext)
I did a test for the not splitter condition and then tried
pContext->m_pNewViewClass=
return CFrameWnd::OnCreateClient(
but that doesn't work.
I've upped the points.
ASKER
Let me rephrase the problem. I've got an application that normally comes up with a splitter window. One of the views displayed is CPictureView. Under some situations I don't need or want a splitter and just want CPictureView to appear.
Some sample code would sure help.
Some sample code would sure help.
You have a CDocument, a CView, and a CFrameWnd class, right? Construct a template by combining those 3 classes (if you haven't already), then do a pDocTemplate->OpenDocument File(NULL) ;
Hope this helps...
Hope this helps...
pDocTemplate = new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CDocument),
RUNTIME_CLASS(CChildFrame) ,
RUNTIME_CLASS(CPictureView ));
AddDocTemplate(pDocTemplat e);
pDocTemplate->OpenDocument File(NULL) ;
IDR_MAINFRAME,
RUNTIME_CLASS(CDocument),
RUNTIME_CLASS(CChildFrame)
RUNTIME_CLASS(CPictureView
AddDocTemplate(pDocTemplat
pDocTemplate->OpenDocument
One last thing, be sure to disable the new open that's default for MDI apps.
In BOOL CMyWinApp::InitInstance()
just before the lines:
if (!ProcessShellCommand(TheC ommandLine Info))
return FALSE;
add in:
if (TheCommandLineInfo.m_nShe llCommand == CCommandLineInfo::FileNew)
TheCommandLineInfo.m_nShel lCommand = CCommandLineInfo::FileNoth ing;
In BOOL CMyWinApp::InitInstance()
just before the lines:
if (!ProcessShellCommand(TheC
return FALSE;
add in:
if (TheCommandLineInfo.m_nShe
TheCommandLineInfo.m_nShel
2 Ashurbanipal
>CMainFrame::OnCreateClien t...
It seems as SDI.
If CPictureView was 1-st view than use "empty" function
BOOL CMainFrame::OnCreateClient (LPCREATES TRUCT lpcs, CCreateContext* pContext)
{
return CFrameWnd::OnCreateClient( lpcs, pContext);
}
if it was the second, replace the view in addition:
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTestNoSplit terDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CPictureView ));
AddDocTemplate(pDocTemplat e);
You can split old and new code with construction like
#ifdef SPLITTER
#else
#endif
>CMainFrame::OnCreateClien
It seems as SDI.
If CPictureView was 1-st view than use "empty" function
BOOL CMainFrame::OnCreateClient
{
return CFrameWnd::OnCreateClient(
}
if it was the second, replace the view in addition:
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTestNoSplit
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CPictureView
AddDocTemplate(pDocTemplat
You can split old and new code with construction like
#ifdef SPLITTER
#else
#endif
No matter which solution you end up using, I don't recommend #ifdef anything. You can use a simple if statement to do the same thing. Using an if statement, you can choose how the program will run with a variable. You could set this variable in any way. For example, a command line argument, a menu item, registry settings, a start-up .ini file, etc...
2 Crius
I suggest #ifdef based on this phrase:
>..depending on build settings?
I suggest #ifdef based on this phrase:
>..depending on build settings?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ashurbanipal,
If the above is not yet making sense, then please post the current contents of your
CMainFrame::OnCreateClient (...
function. We can describe how to modify it to meet your needs.
-- Dan
If the above is not yet making sense, then please post the current contents of your
CMainFrame::OnCreateClient
function. We can describe how to modify it to meet your needs.
-- Dan
ASKER
Your solution seems to work.
The view is displaying some odd problems though and I will post the difficulty in a separate question with separate points.
Thanks
The view is displaying some odd problems though and I will post the difficulty in a separate question with separate points.
Thanks
>..won't work with a single row and single column.
You must have at least 2 columns or 2 rows.
Create an empty second view with split size 0.