Invisible Splitter Window

Similar to "Windows Explorer" with Web Content Enabled

.

Environment: VC6, Windows 2000

When we want to create more than one view in the same view, we go for split windows. What if we don't want that splitter to be visible? (Like what we have in "Windows Explorer," but with Web content enabled.)

The class that I have provided here helps you to successfully hide the splitters. Making the splitter invisible by calling CWnd::ShowWindow(FALSE) won't work because Views are Child windows of the Splitter. When the parent is hidden, the child cannot be visible.

The only way is to override the OnDrawSplitter() function. There is a flag that decides the splitter to be visible or invisible (this is set in the constructor). Here we go...

void CSplitterWndEx::OnDrawSplitter(CDC *pDC, ESplitType nType,
      const CRect &rectArg)
{
  if (pDC == NULL)
  {
    RedrawWindow(rectArg, NULL, RDW_INVALIDATE|RDW_NOCHILDREN);
    return;
  }
  /**
  * If you want to see the splitter window,
  * Use the base class's drawing funcion;
  * otherwise, fill the Splitter with the View's color.
  */
    if(m_Visible)
    {
        CSplitterWnd::OnDrawSplitter(pDC,nType,rectArg);
        return;
    }
  ASSERT_VALID(pDC);
  CRect rect = rectArg;
  CPen WhitePen;
  WhitePen.CreatePen( PS_SOLID, 
                      PEN_WIDTH, 
                      GetSysColor(COLOR_WINDOW));
  pDC->SelectObject(&WhitePen);
  pDC->Rectangle(rect);
}

The next step is to disable the resizing capability of the splitter window. To disable those functionalities, override the following:

  • CSplitterWnd::OnMouseMove(UINT /*nFlags*/, CPoint pt);
  • CSplitterWnd::StartTracking(int ht);
  • CSplitterWnd::OnDrawSplitter(CDC* pDC, ESplitType nType,const CRect& rectArg);
  • CSplitterWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  • CSplitterWnd::OnMouseWheel(UINT fFlags, short zDelta, CPoint point);

This is a very simple way to hide the splitter window.

When using the splitter, call the construcor with FALSE to hide it and TRUE or without any parameter for a normal splitter window.

For an invisible splitter, use this code:

  CSplitterWndEx splitter(FALSE);    //Set visible to FALSE.
  splitter.CreateStatic(this,1,2);
  splitter.CreateView(0,0,RUNTIME_CLASS(CLeftView),
      CSize(120,120),pContext);
  splitter.CreateView(0,1,RUNTIME_CLASS(CTextView),
      CSize(128,0),pContext);

For a visible splitter, use this code:

  CSplitterWndEx splitter(TRUE);    // Set visible to TRUE
                                    // (or)
  CSplitterWndEx splitter;          // Default is TRUE.
                                    // Use the splitter.
  splitter.CreateStatic(this,1,2);
  splitter.CreateView(0,0,RUNTIME_CLASS(CLeftView),
      CSize(120,120),pContext);
  splitter.CreateView(0,1,RUNTIME_CLASS(CTextView),
      CSize(128,0),pContext);

Downloads

Download demo project - 8.00 Kb
Download source - 32.0 Kb



Comments

  • Problems with source code

    Posted by Legacy on 07/12/2002 12:00am

    Originally posted by: The Chameleon

    The source code has problems accepting the stdafx.h

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date