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

The Ultimate Toolbox - Updates and User Contributions

, 12 Feb 2013
Updates and User Contributions for the Ultimate Toolbox Libraries
OutlookDemoUpdate.zip
Ultimate Grid
Demos
OutlookStyle
OutlookStyle.aps
OutlookStyle.dsp
OutlookStyle.dsw
OutlookStyle.suo
res
bitmap1.bmp
bmattach.bmp
bmp00001.bmp
bmp00002.bmp
bmp00003.bmp
Flags.bmp
OutlookStyle.ico
OutlookStyleDoc.ico
Toolbar.bmp
toolbar1.bmp
toolbar2.bmp
toolbarf.bmp
UltimateGrid72_Src_Update01.zip
CellTypes
Include
Source
UltimateGrid72_Src_Update02.zip
DataSources
ODBC
OleDB
EditControls
UltimateGrid72_Src_Update03.zip
UltimateGrid72_Src_Update04.zip
UltimateGrid73_src.zip
BuildDLL
Build DLL.dsp
Build DLL.dsw
res
BuildLib
ugmfclib.dsp
ugmfclib.dsw
Lib
Skel
UltimateTCP-IP42_Src_Update01.zip
Ultimate TCP-IP
Include
Security
Include
Source
source
UltimateTCP-IP42_Src_Update02.zip
Examples
Client
Mail
icon1.ico
icon2.ico
MailClientS.suo
test.dsp
test.dsw
UltimateTCP-IP42_Src_Update03.zip
ultimatetoolbox93_src_update01.zip
Ultimate Toolbox
include
source
UltimateToolbox93_Src_Update02.zip
lib
Build DLLs
Build Libs
UltimateToolbox93_Src_Update03.zip
UltimateToolbox93_Src_Update04.zip
UltimateToolbox93_Src_Update05.zip
/////////////////////////////////////////////////////////////////////////////
// Class Specification : COXSeparator
/////////////////////////////////////////////////////////////////////////////
// OXSeparator.h : header file

// Version: 9.3

// This software along with its related components, documentation and files ("The Libraries")
// is � 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
// governed by a software license agreement ("Agreement").  Copies of the Agreement are
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
// to obtain this file, or directly from our office.  For a copy of the license governing
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.

// //////////////////////////////////////////////////////////////////////////

#ifndef _OXSEPARATOR_H__
#define _OXSEPARATOR_H__

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "OXDllExt.h"


/*

Separator is an example of the simple but very useful control. Separators 
placed in right position in the dialog or form view can greatly improve 
the way your applications look. 

Amazingly, there is no such control among common controls. So we decided 
to fill the gap. We introduce new class COXSeparator that was designed 
primarily to provide easy-to-use separator control.

COXSeparator is derived from CStatic class so you can use standard static 
control to create an object in Dialog Editor. Then you have to associate
CStatic object with the control using Class Wizard and replace the name 
of class CStatic with COXSeparator. 

If you specify any text while creating static control in Dialog Editor 
then it will be displayed in the separator control either. And it will
be placed on the base of static control styles that you specify (SS_LEFT,
SS_RIGHT,SS_CENTER). In order to display just plain separator you shouldn't
associate any text with static conrol in Dialog Editor or you should call
SetWindowText(_T("")) function while initializing controls. By the way, you
can use SetWindowText function to set any text to separator control at 
run-time.

Static control provides the functionality to display only horizontally
aligned text. We go further and provide the functionality to display
separator and associated text vertically. In order to set/remove vertical 
alignment you have to call the following function:


	// --- In  :	bVertOriented	-	if TRUE then separator and control's text 
	//									will be drawn vertically, otherwise -
	//									horizontally (used by default).
	//				bRedraw			-	if TRUE then control will be repainted 
	//									right away
	// --- Out : 
	// --- Returns:	TRUE if success, otherwise FALSE
	// --- Effect : Sets the control orientation (vertical or horizontal)
	void SetVertOriented(BOOL bVertOriented=TRUE, BOOL bRedraw=FALSE)

By default we use horizontal orientation. 

Unfortunately only true type fonts can be used to display text vertically and
usually default Windows font used in controls is not true type. Luckily you just
can use standard SetFont function in order to set any font to separator control.

We also provide customization functionality so you can specify the text color 
and Top/Left and Bottom/Right colors used to draw separator. Use following 
function in order to do that:


	// --- In  :	clrTopLeft		-	color to be used to draw the top/left
	//									side of the separator
	//				clrBottomRight	-	color to be used to draw the 
	//									bottom/right side of the separator
	//				bRedraw			-	if TRUE then control will be repainted 
	//									right away
	// --- Out : 
	// --- Returns:	TRUE if success, otherwise FALSE
	// --- Effect : Sets the separator color
	BOOL SetSeparatorColors(COLORREF clrTopLeft=::GetSysColor(COLOR_BTNSHADOW), 
							COLORREF clrBottomRight=::GetSysColor(COLOR_BTNHILIGHT), 
							BOOL bRedraw=FALSE) 


	// --- In  :	clrText	-	color to be used to draw the control's text
	//				bRedraw	-	if TRUE then control will be repainted 
	//							right away
	// --- Out : 
	// --- Returns:	TRUE if success, otherwise FALSE
	// --- Effect : Sets the text color
	BOOL SetTextColor(COLORREF clrText=::GetSysColor(COLOR_WINDOWTEXT), BOOL bRedraw=FALSE) 



Take at the "Separator" sample that demonstrate different separators.
It can be found in .\Samples\GUI\Separator subdirectory of your
Ultimate Toolbox directory.

*/

/////////////////////////////////////////////////////////////////////////////
// COXSeparator window

class OX_CLASS_DECL COXSeparator : public CStatic
{
// Construction
public:
	// --- In  :
	// --- Out : 
	// --- Returns:
	// --- Effect : Constructs the object
	COXSeparator();

// Attributes
public:

protected:
	// text color
	COLORREF m_clrText;
	// color of top/left line of the separator
	COLORREF m_clrTopLeft;
	// color of bottom/right line of the separator
	COLORREF m_clrBottomRight;
	// flag that specifies whether the separator should be drawn 
	// vertically (the control is horizontally oriented by default)
	BOOL m_bVertOriented;

private:
	// window's text
	CString m_sText;


// Operations
public:
	// --- In  :	clrText	-	color to be used to draw the control's text
	//				bRedraw	-	if TRUE then control will be repainted 
	//							right away
	// --- Out : 
	// --- Returns:	TRUE if success, otherwise FALSE
	// --- Effect : Sets the text color
	inline BOOL SetTextColor(COLORREF clrText=::GetSysColor(COLOR_WINDOWTEXT), 
		BOOL bRedraw=FALSE) 
	{ 
		if(bRedraw && m_clrText==clrText)
			bRedraw=FALSE;
		m_clrText=clrText;
		if(bRedraw)
			RedrawWindow();
		return TRUE;
	}

	// --- In  :	clrText	-	reference to COLORREF variable that will be set 
	//							to the color currently used to draw the 
	//							control's text
	// --- Out : 
	// --- Returns:	TRUE if success, otherwise FALSE
	// --- Effect : Retrieves the text color
	inline BOOL GetTextColor(COLORREF& clrText) const 
	{ 
		clrText=m_clrText; 
		return TRUE;
	}

	// --- In  :	clrTopLeft		-	color to be used to draw the top/left
	//									side of the separator
	//				clrBottomRight	-	color to be used to draw the 
	//									bottom/right side of the separator
	//				bRedraw			-	if TRUE then control will be repainted 
	//									right away
	// --- Out : 
	// --- Returns:	TRUE if success, otherwise FALSE
	// --- Effect : Sets the separator color
	inline BOOL SetSeparatorColors(COLORREF clrTopLeft=::GetSysColor(COLOR_BTNSHADOW), 
		COLORREF clrBottomRight=::GetSysColor(COLOR_BTNHILIGHT), BOOL bRedraw=FALSE) 
	{ 
		if(bRedraw && m_clrTopLeft==clrTopLeft && 
			m_clrBottomRight==clrBottomRight)
			bRedraw=FALSE;
		m_clrTopLeft=clrTopLeft; 
		m_clrBottomRight=clrBottomRight;
		if(bRedraw)
			RedrawWindow();
		return TRUE;
	}

	// --- In  :	clrTopLeft		-	reference to COLORREF variable that 
	//									will be set to the color currently 
	//									used to draw the top/left side of the 
	//									separator
	//				clrBottomRight	-	reference to COLORREF variable that 
	//									will be set to the color currently 
	//									used to draw the bottom/right side 
	//									of the separator
	// --- Out : 
	// --- Returns:	TRUE if success, otherwise FALSE
	// --- Effect : Retrieves the separator color
	inline BOOL GetSeparatorColors(COLORREF& clrTopLeft, COLORREF& clrBottomRight) const 
	{ 
		clrTopLeft=m_clrTopLeft; 
		clrBottomRight=m_clrBottomRight;
		return TRUE;
	}

	// --- In  :	bVertOriented	-	if TRUE then separator and control's text 
	//									will be drawn vertically, otherwise -
	//									horizontally (used by default).
	//				bRedraw			-	if TRUE then control will be repainted 
	//									right away
	// --- Out : 
	// --- Returns:	TRUE if success, otherwise FALSE
	// --- Effect : Sets the control orientation (vertical or horizontal)
	inline void SetVertOriented(BOOL bVertOriented=TRUE, BOOL bRedraw=FALSE)
	{
		if(bRedraw && m_bVertOriented==bVertOriented)
			bRedraw=FALSE;
		m_bVertOriented=bVertOriented;
		if(bRedraw)
			RedrawWindow();
	}

	// --- In  :	
	// --- Out : 
	// --- Returns:	TRUE if the text and separator will be drawn vertically, 
	//				FALSE if the text and separator will be drawn horizontally
	// --- Effect : Retrieves the flag that specifies whether the control 
	//				is vertically or horizontally oriented
	inline BOOL IsVertOriented() const
	{
		return m_bVertOriented;
	}


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(COXSeparator)
	protected:
	virtual void PreSubclassWindow();
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~COXSeparator();
	// --- In  :
	// --- Out : 
	// --- Returns:
	// --- Effect : Object's destructor

	// Generated message map functions
protected:
	//{{AFX_MSG(COXSeparator)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnPaint();
	
	// v9.3 - update 03 - 64-bit - changed these to LRESULT, WPARAM, LPARAM from LONG, UINT, LONG
	afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnGetText(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnGetTextLength(WPARAM wParam, LPARAM lParam);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(_OXSEPARATOR_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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

The Ultimate Toolbox
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.
 
Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
Group type: Organisation

379 members


| Advertise | Privacy | Mobile
Web02 | 2.8.140814.1 | Last Updated 13 Feb 2013
Article Copyright 2008 by The Ultimate Toolbox
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid