SDI split view with view not visible

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.
LVL 1
pcj0961Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mikeblasCommented:
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
pcj0961Author Commented:
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
mikeblasCommented:

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

pcj0961Author Commented:
Bingo !!!! thanks for the code and information



0
pcj0961Author Commented:
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
mikeblasCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.