Click here to Skip to main content
15,879,535 members
Articles / Desktop Programming / MFC

ZSplitter: Adding Automatic Splitting for Dialog Controls

Rate me:
Please Sign up or sign in to vote.
4.88/5 (14 votes)
28 May 2001 633.1K   6.4K   58  
A set of classes that provide automatic adding necessary splitters in your dialogs
/*@ ZSplitter.h                                Version from  10.11.98 17:04  */
/*                                              Created on  08.12.97 15:29  */
/* Contents-----------------------------------------------------------------**
**                                                                          **
**  Control for slite windows                                               **
**                                                                          **
$*                                                                          */
/*--------------------------------------------------------------------------**
** Designed by Melnikov Mike                                                **
** COPYRIGHT (C) 1997 by Nestor Crew of Animatek Inc.                       **
** All rights reserved.                                                     **
** -------------------------------------------------------------------------*/
#ifndef _NestorSplitter_h_
#define _NestorSplitter_h_

#include <vector>
using namespace std;


#define WM_MOVE_ZSPLITTER WM_USER + 110

enum SplitterStyle
{
    sp_StyleNone    = 0x00000,
    sp_StyleTop     = 0x00001,
    sp_StyleBottom  = 0x00002,
    sp_StyleLeft    = 0x00004,
    sp_StyleRight   = 0x00008,
    sp_StyleHoriz   = sp_StyleLeft|sp_StyleRight,
    sp_StyleVert    = sp_StyleTop|sp_StyleBottom,
    sp_StyleRect    = sp_StyleVert|sp_StyleHoriz,
    sp_StyleSplit   = 0x0000F,
    sp_StyleHorizSplit = sp_StyleSplit | sp_StyleHoriz,
    sp_StyleVertSplit  = sp_StyleSplit | sp_StyleVert,
};

class ZSplitter : public CWnd
{
  public:
    ZSplitter();
    ~ZSplitter();

  public:
    void    addWindow(int idx,int style);
    void    setStyle(int style) {ownStyle=style;}
    void    move(CPoint,CPoint);
  public:

  // --------------------------------------------------------- implementation
  protected:
    CPoint                    m_pointDragStart;
    bool                      m_bInDragTestNow;

    afx_msg void OnMouseMove( UINT nFlags, CPoint point );
    afx_msg void OnLButtonDown( UINT nFlags, CPoint point );
    afx_msg void OnLButtonUp( UINT nFlags, CPoint point );
    afx_msg void OnRButtonDown( UINT nFlags, CPoint point );
    afx_msg void OnRButtonUp( UINT nFlags, CPoint point );

    BOOL  OnSetCursor( CWnd* pWnd, UINT nHitTest, UINT message );

    void releaseCapture();
    bool countRect( CRect& rect, int idx,CPoint dif);

    vector<int>             idxs;
    vector<int>             styles;
    int                     ownStyle;

  DECLARE_DYNAMIC(ZSplitter)
	DECLARE_MESSAGE_MAP()
};

class ZSplitter2 : public ZSplitter
{
 public:
  typedef ZSplitter inherited;

  BOOL Create( CWnd* pParentWnd, DWORD dwStyle,UINT nID)
  {
    CREATESTRUCT cs;  memset(&cs, 0, sizeof(cs));
    cs.lpszClass = AfxRegisterWndClass(CS_DBLCLKS,::LoadCursor(0,IDC_ARROW));
    cs.style = dwStyle;
    cs.hInstance = AfxGetInstanceHandle();
    cs.hwndParent = pParentWnd->GetSafeHwnd();
    return inherited::Create( cs.lpszClass, cs.lpszName, cs.style, CRect(0,0,0,0), pParentWnd,nID);
  }
  virtual void OnPaint()
  {
    CPaintDC  dc(this);
    CRect rc; 
    GetClientRect(&rc);
    dc.FillSolidRect(&rc,GetSysColor(COLOR_WINDOW));
    //dc.Draw3dRect(&rc, RGB(255, 0, 0), RGB(0, 255, 0));
  }
  DECLARE_MESSAGE_MAP()
};


#endif // _NestorSplitter_h_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Web Developer
Russian Federation Russian Federation
Mike has been programming in C/C++ for 11 years and Visual C++/MFC for 4 years. His background includes pure and applied mathematics, engineering and physics, and he is currently based in Moscow, Russia.

Comments and Discussions