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 CPOL
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 Declaration : CUGCTDateTimePicker
**************************************************************************
	Source file : UGCTdtp.cpp
	Header file : UGCTdtp.h
// 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.

	Purpose
		Displays a button along with a cell that can be used to activate
		a full featured Date-Time picker
	Details
		Extended Styles
			UGCT_DROPLISTHIDEBUTTON - if set the button that activates the
				date-time picker is not shown until the cell has focus
		Notifictions
			UGCT_CONVERTDATE - see below for full details
			UGCT_DISPLAYMONTHCAL - see below for full details
*************************************************************************/

#ifndef _UGCTdtp_H_
#define _UGCTdtp_H_

#if _MFC_VER>0x0421

#include <afxdtctl.h>

// The notification ID that is sent to CUGCtrl in form of OnCellTypeNotify()
// function. By handling this notification you can customize the format for
// converting date to string. Argument param of this function will point 
// to UGCTCONVERTDATE structure. This structure contains COleDateTime object 
// to be converted and CString object to save the converted data
// 
#define UGCT_CONVERTDATE			200


// The notification ID that is sent to CUGCtrl in form of OnCellTypeNotify()
// function. By handling this notification you can customize the appearance
// of the popup calendar control. Argument param of this function will point 
// to UGCTMONTHCALSETTINGS structure. This structure contains information 
// related to the calendar control settings
#define UGCT_DISPLAYMONTHCAL		201



// UGCTCONVERTDATE is designed to allow a programmer to specify the format for
// converting date to string. Pointer to an object of this structure
// is sent as param argument in CUGCtrl::OnCellTypeNotify() function 
// (notification ID is UGCT_CONVERTDATE). Here is the description of all 
// structure members:
//			date	-	COleDateTime object to convert to string
//			string	-	CString object to save the formated date
//
typedef struct UG_CLASS_DECL _tagUGCTCONVERTDATE
{
	COleDateTime date;
	CString string;
} UGCTCONVERTDATE;
//
/////////////////////////////////////////////////////////////////////////////////////


// UGCTMONTHCALSETTINGS is designed to allow a programmer to customize the 
// appearance of the popup calendar control. Pointer to an object of this 
// structure is sent as param argument in OnCellTypeNotify() function 
// (notification ID is UGCT_DISPLAYMONTHCAL). The elements of this structure 
// will be set to default values. You can change any of them. Here is the
// description of all structure members
//			nFlags			-	0 or any combination of the following flags:
//								MCS_WEEKNUMBERS
//								MCS_NOTODAYCIRCLE
//								MCS_NOTODAY
//								Refer to the SDK documentation for details on 
//								these flags
//			nFirstDayOfWeek	-	number of first day of the week as it will be 
//								displayed in the calendar control (0 - Monday,
//								1 - Tuesday, ...)
//			nScrollRate		-	the number of months the control's contents
//								will be scrolled back/ahead when scroll button 
//								is pressed
//			szDimension		-	cx element of this CSize object specifies the 
//								number of months displayed horizontally, 
//								cy element specifies the number of months displayed 
//								horizontally
//			lf				-	LOGFONT structure that defines the font that will 
//								be used to display the calendar contents
//			clrBk			-	the background color displayed between months
//			clrText			-	the color used to display text within a month
//			clrMonthBk		-	the background color displayed within the month
//			clrTitleText	-	he color used to display text within the calendar's 
//								title
//			clrTitleBk		-	the background color displayed in the calendar's 
//								title
//			clrTrailingText	-	the color used to display header and trailing-day 
//								text. Header and trailing days are the days from the 
//								previous and following months that appear on the 
//								current calendar
//			dateCur			-	date to be selected as current one
//
typedef struct UG_CLASS_DECL _tagUGCTMONTHCALSETTINGS
{
	int nFlags;
	int nFirstDayOfWeek;
	int nScrollRate;
	CSize szDimension;
	LOGFONT lf;
	COLORREF clrBk;
	COLORREF clrText;
	COLORREF clrMonthBk;
	COLORREF clrTitleText;
	COLORREF clrTitleBk;
	COLORREF clrTrailingText;
	COleDateTime dateCur;
} UGCTMONTHCALSETTINGS;
//
/////////////////////////////////////////////////////////////////////////////////////


class UG_CLASS_DECL CUGCTDateTimePicker: public CUGCellType
{
	// width of the dropdown button
	int		m_btnWidth;
	// internal flag. Set to TRUE if dropdown button is currently pressed
	int		m_btnDown;
	// current rectangle for the dropdown button
	RECT	m_btnRect;
	// coordinates of the currently displayed cell
	int		m_btnCol;
	long	m_btnRow;

	// pens used to draw the cell contents
	CPen	m_Darkpen;
	CPen	m_Lightpen;
	CPen	m_Facepen;
	CPen	m_pen;
	CBrush	m_brush;

protected:

	// internal flag. Set to TRUE if popup calendar is currently displayed
	BOOL	m_bActiveMonthCal;


protected:
	// displays month calendar for current cell
	int DisplayMonthCalendar();

	// --- In  :	date	-	COleDateTime object that represents the date 
	//							to be formated into the string
	// --- Out :	string	-	the result of the conversion of the specified
	//							COleDateTime object in the string
	// --- Returns:
	// --- Effect : Converts COleDateTime object into a string. Advanced 
	//				overridable, use your own implementation in order to save
	//				the date that was chosen by a user into the cell
	//				(cell saves data internally as a string)
	virtual void ConvertDateToString(COleDateTime& date, CString& string);

	// --- In  :	string	-	CString object that represents the string 
	//							to be parsed into the COleDateTime object
	// --- Out :	date	-	the result of the conversion of the specified
	//							CString object in the COleDateTime object
	// --- Returns:
	// --- Effect : Converts CString object into a COleDateTime object. Advanced 
	//				overridable, use your own implementation in order to convert
	//				the cell string data into a date (cell saves data internally 
	//				as a string)
	virtual BOOL ConvertStringToDate(CString& string, COleDateTime& date);


	// --- In  :	pRect	-	points to the rectangle that defines the position
	//							of the calendar control in screen coordinates
	// --- Out :	
	// --- Returns:
	// --- Effect : Adjusts the position of the calendar control window before 
	//				displaying it. Advanced overridable, use your own implementation 
	//				in order to position the calendar control window in a specific way
	virtual void AdjustMonthCalPosition(RECT* pRect);
	
public:

	// --- In  :
	// --- Out : 
	// --- Returns:
	// --- Effect : Constructs the object
	CUGCTDateTimePicker();

	// --- In  :
	// --- Out : 
	// --- Returns:
	// --- Effect : Destructs the object
	~CUGCTDateTimePicker();


	//overloaded CUGCellType functions
	virtual LPCTSTR GetName();
	virtual LPCUGID GetUGID();
	virtual int GetEditArea(RECT *rect);
	virtual BOOL OnLClicked(int col,long row,int updn,RECT *rect,POINT *point);
	virtual BOOL OnDClicked(int col,long row,RECT *rect,POINT *point);
	virtual BOOL OnKeyDown(int col,long row,UINT *vcKey);
	virtual BOOL OnCharDown(int col,long row,UINT *vcKey);
	virtual BOOL OnMouseMove(int col,long row,POINT *point,UINT flags);
	virtual void OnKillFocus(int col,long row,CUGCell *cell);	
	virtual void OnDraw(CDC *dc,RECT *rect,int col,long row,CUGCell *cell,int selected,int current);
	virtual void GetBestSize(CDC *dc,CSize *size,CUGCell *cell);

	static BOOL SetMonthCalDimension(CMonthCalCtrl* pMonthCal, CSize szDimension,
		CSize szMargins=CSize(0,0));
	static BOOL GetMonthCalReqRect(CMonthCalCtrl* pMonthCal, RECT* pRect, 
		CSize szDimension);
};
#endif	//_MFC_VER>0x0421
#endif  //#ifndef _UGCTdtp_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

400 members


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