Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Custom Tab Controls, Tabbed Frame and Tabbed MDI

, 13 Jul 2005
An extensible framework for creating customized tabs in ATL/WTL, with a VS.NET-like tab control implementation, tabbed frames, tabbed MDI, and more.
tabbingframework_demo.zip
TabbedSDISplitter
Release
TabbedSDISplitter.exe
res
Doc.ico
folder_c.ico
folder_o.ico
TabbedSDISplitter.exe.manifest
TabbedSDISplitter.ico
toolbar.bmp
TabbedSDISplitter.dsp
TabbedSDISplitter.dsw
TabDemo
Release
TabDemo.exe
res
error.ico
folder_closed.ico
folder_open.ico
info.ico
log.ico
TabDemo.exe.manifest
TabDemo.ico
TabDemodoc.ico
toolbar.bmp
warning.ico
TabDemo.dsp
TabDemo.dsw
DockingDemo
DockingDemo.dsp
DockingDemo.dsw
Release
DockingDemo.exe
res
DockingDemo.exe.manifest
DockingDemo.ico
DockingDemodoc.ico
error.ico
folder_closed.ico
folder_open.ico
info.ico
log.ico
msdev_tab_icons.bmp
toolbar.bmp
warning.ico
include
Sergey Klimov
SimpleTabbedMDIDemo
Release
SimpleTabbedMDIDemo.exe
res
SimpleTabbedMDIDemo.exe.manifest
SimpleTabbedMDIDemo.ico
SimpleTabbedMDIDemodoc.ico
toolbar.bmp
SimpleTabbedMDIDemo.dsp
SimpleTabbedMDIDemo.dsw
tabbingframework_history.zip
tabbingframework_priorhistory.zip
tabbingframework_src.zip
// Copyright (c) 2002
// Sergey Klimov (kidd@ukr.net)
// WTL Docking windows
//
// This code is provided "as is", with absolutely no warranty expressed
// or implied. Any use is at your own risk.
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is
// not sold for profit without the authors written consent, and
// providing that this notice and the authors name is included. If
// the source code in  this file is used in any commercial application
// then a simple email woulod be nice.

#ifndef __WTL_DW__SIMPLESPLITTERBAR_H__
#define __WTL_DW__SIMPLESPLITTERBAR_H__

#pragma once

#ifndef __ATLMISC_H__
        #error SimpleSplitterBar.h requires atlmisc.h to be included first
#endif

namespace dockwins{

template<long TThickness=5>
class CSimpleSplitterBar :  public CRect
{
public:
	enum{sbThickness=TThickness};

	CSimpleSplitterBar(bool bHorizontal=true)
		:m_bHorizontal(bHorizontal)
	{
		SetRectEmpty();
	}
	CSimpleSplitterBar(const CSimpleSplitterBar& ref)
		:CRect(ref),m_bHorizontal(ref.IsHorizontal())
	{

	}
	static long GetThickness()
	{
		return sbThickness;
	}
	void SetOrientation(bool bHorizontal)
	{
		m_bHorizontal=bHorizontal;
	}
	bool IsHorizontal() const
	{
		return m_bHorizontal;
	}

	bool IsPtIn(const CPoint& pt) const
	{
		return (PtInRect(pt)!=FALSE);
	}

	HCURSOR GetCursor(const CPoint& pt) const
	{
		HCURSOR hCursor=NULL;
		if(IsPtIn(pt))
		{
			CDWSettings settings;
			 hCursor=((IsHorizontal())
								?settings.HResizeCursor()
								:settings.VResizeCursor());
		}
		return hCursor;
	}

    void Draw(CDC& dc) const
    {
        dc.FillRect(this, (HBRUSH)LongToPtr(COLOR_3DFACE + 1));
    }
	void DrawGhostBar(CDC& dc) const
	{
        CBrush brush = CDCHandle::GetHalftoneBrush();
        if(brush.m_hBrush != NULL)
        {
            HBRUSH hBrushOld = dc.SelectBrush(brush);
            dc.PatBlt(this->left, this->top,this->Width(),this->Height(), PATINVERT);
            dc.SelectBrush(hBrushOld);

        }

	}
	void CleanGhostBar(CDC& dc) const
	{
		DrawGhostBar(dc);
	}
protected:
	bool m_bHorizontal;
};


template<long TThickness=5>
class CSimpleSplitterBarEx: public CSimpleSplitterBar<TThickness>
{
	typedef CSimpleSplitterBar<TThickness> baseClass;
public:
	CSimpleSplitterBarEx(bool bHorizontal=true)
		:baseClass(bHorizontal)
	{
	}
	CSimpleSplitterBarEx(const CSimpleSplitterBarEx& ref)
		:baseClass(ref)
	{

	}

    void Draw(CDC& dc) const
    {
        dc.FillRect(this, (HBRUSH)LongToPtr(COLOR_3DFACE + 1));
		CRect rc(*this);
//		dc.DrawEdge(&rc, EDGE_RAISED, (IsHorizontal()) ? (BF_TOP | BF_BOTTOM) : (BF_LEFT | BF_RIGHT) );
		dc.DrawEdge(&rc, BDR_RAISEDINNER, (IsHorizontal()) ? (BF_TOP | BF_BOTTOM) : (BF_LEFT | BF_RIGHT) );

    }

};

template<class T>
class CSimpleSplitterBarSlider
{
	typedef T CSplitter;
	typedef CSimpleSplitterBarSlider<CSplitter> thisClass;
public:
	CSimpleSplitterBarSlider(CSplitter& splitter)
		:m_splitter(splitter)
	{
		if(!m_splitter.IsHorizontal())
		{
			m_pTop=&m_splitter.left;
			m_pDependant=&m_splitter.right;
		}
		else
		{
			m_pTop=&m_splitter.top;
			m_pDependant=&m_splitter.bottom;
		}
	}
	operator long() const
	{
		return *m_pTop;
	}

	long operator=(long val)
	{
		*m_pDependant=val+m_splitter.GetThickness();
		return *m_pTop=val;
	}

	thisClass& operator += (long val)
	{
		*this=*this+val;
		return *this;
	}
	thisClass& operator -= (long val)
	{
		*this=*this-val;
		return *this;
	}

protected:
	CSplitter& m_splitter;
	long	*m_pTop;
	long	*m_pDependant;
};

}//namespace dockwins

#endif // __WTL_DW__SIMPLESPLITTERBAR_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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Daniel Bowen
Architect
United States United States
Daniel Bowen used to work as a Software Engineer for Evans & Sutherland in Salt Lake City, Utah working on the modeling tools for high end flight simulators. He then worked for the startup company WiLife Inc. in Draper, Utah working on the software portion of an easy to use and affordable digital video surveillance system. WiLife Inc. is now part of Logitech Inc.

| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 14 Jul 2005
Article Copyright 2002 by Daniel Bowen
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid