Solved

SDI split view with view not visible

Posted on 1998-02-26
6
441 Views
Last Modified: 2013-11-20
I am creating an SDI application where the doc\view
structure is initialized, a static splitter is created (two different views), the frame is displayed (tool bars, status bar, etc ...) with only the client area of the SDI main frame displayed (want to show a bitmap background) not the split views. I would then like a toolbar button to activate/deactivate (display/not display) the split views (at the same time). How do I make the views displayable/non-displayable in a splitter application ?. Some code would be helpful but a
general direction would be good enough.
0
Comment
Question by:pcj0961
  • 3
  • 3
6 Comments
 
LVL 11

Expert Comment

by:mikeblas
Comment Utility
To remove one of the windows, call DelteView() on your splitter.  The two integers are the zero-based row and column of the view you want to delete.

To add a view again, call CreateView() on your splitter. You'll need the zero-based row and column again, and you'll want to get the runtime class information for your view. The CCreateContext pointer can be NULL, if you want your new view to be based on the same document as the other pane.  So, a simple call would look like this:

    CSize size(100, 100);

    if (!CreateView(0, 0, RUNTIME_CLASS(CYourView), size, &ctxt))
    {
       TRACE("Failed!\n");
       return -1;
    }

otherwise, you'll need to initialize the m_pCurrentDoc member (only!) of the object and pass it along.

.B ekiM


0
 
LVL 1

Author Comment

by:pcj0961
Comment Utility
Mike,
I guess I'm a little confused about your answer. It sounds to me like your answer will allow me to display 1 or 2 split views. I wish to display none or both.
In the OnCreateClient function I wish to setup a statically split
window (2 views) but I don't want either view to be displayed.
In My SDI MainFrame I'm using OnEraseBkgnd to paint a bitmap
background in the client area. When I press a toolbar I want both views to be displayed (hide the bitmap). Now if this is not possible, can I display my bitmap background in one of the views of the splitter and hide the other one and when I add in the 2nd view (using the toolbar) of the splitter I can change the first view (that had the bitmap in it ) to point to a new view displaying the data I want.
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 10 total points
Comment Utility

Oh!  Then, just hide the whole splitter window:

void CMainFrame::OnToggleSplitterVisible()
{
   if (m_wndSplitter.IsWindowVisible())
   {
      m_wndSplitter.ShowWindow(SW_HIDE);
      Invalidate();
   }
   else
      m_wndSplitter.ShowWindow(SW_RESTORE);
}

You'll need to be careful with two things:

1) An SDI splitter window is normally created with a null background brush, so it never erases its own background. (That reduces flashing and helps performance stay snappy in most normal apps.)  If you're painting a bitmap in response to WM_ERASEBKGND, that's fine; but you'll need to make sure that code works right and that it will erase the entire background client area.

2) You'll want to make sure that the splitter UI is deactivated. For example, if the splitter window isn't visible, you'll want to make sure the "Split" command on the "View" menu gets disabled.

Maybe you have bigger UI things to fix, like turning off the save and load menus. If you don't want users to do file operations (you don't mention), you might consider destroying and recreating the splitter window completely instead of just hiding and showing.

.B ekiM


0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 1

Author Comment

by:pcj0961
Comment Utility
Bingo !!!! thanks for the code and information



0
 
LVL 1

Author Comment

by:pcj0961
Comment Utility
Mike,
before we put this issue to rest, you mentioned destroying and recreating the splitter. How can that be done when the splitter is created when the main frame window is created ?.
0
 
LVL 11

Expert Comment

by:mikeblas
Comment Utility
If you're using AppWizard-created code, your frame window manages the splitter. It has a CSplitterWnd member named m_wndSplitter. When the frame is created, MFC fires the OnCreateClient() event and the AppWizard has given you code to create the splitter window there.

You can destroy the window at any time just by calling DestroyWindow() on that member. That'll destroy the views and the document, too, so you might want to offer the user a chance to save their work.

You can recreate the splitter by:

1) Creating a new document
2) Creating a single new view
3) doing the same splitter creation work your OnCreateClient() code does.

.B ekiM

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now