Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

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.
0
pcj0961
Asked:
pcj0961
  • 3
  • 3
1 Solution
 
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now