Invisible Splitter Window | CodeGuru

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Jul 11, 2002
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.