?
Solved

SDI split view with view not visible

Posted on 1998-02-26
6
Medium Priority
?
451 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 40 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

719 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