Solved

SDI split view with view not visible

Posted on 1998-02-26
6
446 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 11

Expert Comment

by:mikeblas
ID: 1316579
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
ID: 1316580
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
ID: 1316581

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
Industry Leaders: 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!

 
LVL 1

Author Comment

by:pcj0961
ID: 1316582
Bingo !!!! thanks for the code and information



0
 
LVL 1

Author Comment

by:pcj0961
ID: 1316583
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
ID: 1316584
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 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