Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Draw splitterWnd like one in PageNavigator Collapse All
Subject Author Date
Chris Douglass May 26, 2005 - 10:00 AM

Hi guys!


I want to create a custom CExtSplitterWnd that manages two vertical panes (1 row and 2 columns) and splits two non-CView dialog wnd’s.  My goal is to achieve a look and feel for the entire splitter window that mimics the splitter bar in the PageNavigator complete with the 9 dots or so in the center of the splitter. 


So, essentially I want to use the splitter bar in PageNavigator but orient it vertically and make it split two static panes.


Can you give me some pointers on how to accomplish this?  My SDI application does not use MFC’s doc/view architecture.  The two panes being split are two CDialog based wnd’s.  They will be static so using CreateStatic seems to be the best option for creating the splitter.


Thanks for any ideas!

Technical Support May 30, 2005 - 10:12 AM

If you need a splitter that paints dots, you need to use a CExtSplitterWnd-class that has an OnDrawSplitter method like in the code below:

class CPNSplitterWnd : public CExtSplitterWnd
{
public:
      CPNSplitterWnd()
      {
            m_cxSplitterGap = 4;
            m_cySplitterGap = 4;
      }     
protected:
      virtual void OnDrawSplitter(
            CDC * pDC,
            ESplitType nType,
            const CRect & rectArg
            )
      {
            if( pDC == NULL)
            {
                  RedrawWindow(
                        rectArg, 
                        NULL, 
                        RDW_INVALIDATE
                              |RDW_NOCHILDREN
                        );
                  return;
            }
            ASSERT_VALID(pDC);
            CRect rect( rectArg );        
            CRect rcClient;
            GetClientRect( &rcClient );
            CRect rcClientInner( rcClient );
            rcClientInner.DeflateRect(
                  2*CX_BORDER,
                  2*CX_BORDER
                  );
            switch( nType )
            {
            case splitBorder:
                  pDC->ExcludeClipRect(
                        &rcClientInner
                        );
                  g_PaintManager->PaintDockerBkgnd( 
                        true,
                        *pDC,  
                        rcClient,
                        rect
                        );
                  pDC->SelectClipRgn( NULL );
                  return;
            case splitBar:
            case splitIntersection:
                  break;
            case splitBox:
                  pDC->ExcludeClipRect(
                        &rcClientInner
                        );
                  g_PaintManager->PaintDockerBkgnd( 
                        true,
                        *pDC,  
                        rcClient,
                        rect
                        );
                  pDC->SelectClipRgn( NULL );
                  break;
#ifdef _DEBUG
            default:
                  {
                        ASSERT( FALSE );
                  }
                  break;
#endif // _DEBUG
            } // switch( nType )
            rect.right =
                  rect.left + m_cySplitterGap;
            pDC->FillSolidRect(
                  rect, 
                  g_PaintManager->GetColor(
                        CExtPaintManager::CLR_3DFACE_OUT,
                        (CObject*)this
                        )
                  );
 
            const CSize szGripDot(2,2);
            const CSize szGripDist(1,1);
            const CSize szGripShadowOffset(1,1);
            const INT nDotCount = 9;
 
            INT nDotsAreaWidth = szGripDot.cx + szGripShadowOffset.cx;
            INT nDotsAreaHeight = nDotCount * ( szGripDot.cy + szGripDist.cy + szGripShadowOffset.cy );
 
            CRect rcDotArea( rect );
            rcDotArea.DeflateRect( 
                  ( rect.Width() - nDotsAreaWidth ) / 2 + 1, 
                  ( rect.Height() - nDotsAreaHeight ) / 2
                  );
 
            for( INT nDot = 0; nDot < nDotCount; nDot++ )
            {
                  INT nOffsetY = nDot * (szGripDot.cy + szGripShadowOffset.cy + szGripDist.cy);
                  CRect rcDot( 
                        rcDotArea.left,
                        rcDotArea.top + nOffsetY,
                        rcDotArea.left + szGripDot.cx,
                        rcDotArea.top + nOffsetY + szGripDot.cy
                        );
 
                  CRect rcShadow( rcDot );
                  rcShadow.OffsetRect( szGripShadowOffset );
                  pDC->FillSolidRect( 
                        &rcShadow, 
                        g_PaintManager->GetColor( COLOR_WINDOW, this ) 
                        );
                  pDC->FillSolidRect( 
                        &rcDot, 
                        g_PaintManager->GetColor( COLOR_3DDKSHADOW, this ) 
                        );
            } // for( INT nDot = 0; nDot < nDotCount; nDot++ )
      }
}; // class CPNSplitterWnd