Solved

problem with splitter windowsI

Posted on 2002-05-17
15
208 Views
Last Modified: 2013-11-20
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?
0
Comment
Question by:Ashurbanipal
  • 6
  • 4
  • 3
  • +2
15 Comments
 
LVL 16

Expert Comment

by:AlexNek
ID: 7016559
2 Ashurbanipal
>..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.
0
 
LVL 4

Expert Comment

by:mblat
ID: 7016720
And you also can prevent user from "opening" empty part of splitter.
0
 

Author Comment

by:Ashurbanipal
ID: 7017005
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?
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 3

Expert Comment

by:Crius
ID: 7017092
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?
0
 

Author Comment

by:Ashurbanipal
ID: 7017124
What you say makes sense in theory, it's applying it to the problem that's giving me grief.


In CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs,
     CCreateContext* pContext)

I did a test for the not splitter condition and then tried
          pContext->m_pNewViewClass=RUNTIME_CLASS(CPictureView);
return CFrameWnd::OnCreateClient(lpcs,pContext);
but that doesn't work.

I've upped the points.
0
 

Author Comment

by:Ashurbanipal
ID: 7017211
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.
0
 
LVL 3

Expert Comment

by:Crius
ID: 7017362
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->OpenDocumentFile(NULL);

Hope this helps...
0
 
LVL 3

Expert Comment

by:Crius
ID: 7017371
   pDocTemplate = new CMultiDocTemplate(
         IDR_MAINFRAME,
         RUNTIME_CLASS(CDocument),
         RUNTIME_CLASS(CChildFrame),
         RUNTIME_CLASS(CPictureView));
    AddDocTemplate(pDocTemplate);

pDocTemplate->OpenDocumentFile(NULL);
0
 
LVL 3

Expert Comment

by:Crius
ID: 7017379
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(TheCommandLineInfo))
         return FALSE;

add in:
    if (TheCommandLineInfo.m_nShellCommand == CCommandLineInfo::FileNew)
     TheCommandLineInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
0
 
LVL 16

Expert Comment

by:AlexNek
ID: 7017436
2 Ashurbanipal
>CMainFrame::OnCreateClient...
It seems as SDI.

If CPictureView was 1-st view than use "empty" function

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT 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(CTestNoSplitterDoc),
          RUNTIME_CLASS(CMainFrame),       // main SDI frame window
          RUNTIME_CLASS(CPictureView));
     AddDocTemplate(pDocTemplate);

You can split old and new code with construction like
#ifdef SPLITTER
#else
#endif
0
 
LVL 3

Expert Comment

by:Crius
ID: 7017454
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...
0
 
LVL 16

Expert Comment

by:AlexNek
ID: 7017475
2 Crius
I suggest #ifdef based on this phrase:
>..depending on build settings?

0
 
LVL 3

Accepted Solution

by:
Crius earned 200 total points
ID: 7017489
Yes, I read that specification. I disagree with it because I believe there is a better way. Your suggestion does answer what he is asking, but I am proposing what I consider to be a better way of doing things - beyond what is being asked/wanted.

Nothing personal AlexNek. :) I commonly suggest what I think are better solutions for accomplishing something, even if they are considerably different than what is being asked.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7018469
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
0
 

Author Comment

by:Ashurbanipal
ID: 7022419
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
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question