/** * @file XTPMaskEdit.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPMASKEDIT_H__) # define __XTPMASKEDIT_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * CXTPMaskEdit is a CXTPEdit derived class. It allows text masking to be * applied to the control to format it for special editing restrictions. */ class _XTP_EXT_CLASS CXTPMaskEdit : public CXTPEdit { /** @cond */ DECLARE_DYNAMIC(CXTPMaskEdit) /** @endcond */ public: /** * @brief * Constructs a CXTPMaskEdit object. */ CXTPMaskEdit(); /** * @brief * Initializes the CXTPMaskEdit control. * @details * Call this member function to initialize the edit control. You can * call this after you have created or subclassed your edit control. * @param pParentWnd Pointer to the parent of the edit control. * @return * true if the control was successfully initialized, otherwise false. */ virtual bool Initialize(CWnd* pParentWnd); }; /** * @brief * CXTPDateEdit is a CXTPMaskEdit derived class. It is specifically * geared toward editing date fields. */ class _XTP_EXT_CLASS CXTPDateEdit : public CXTPMaskEdit { /** @cond */ DECLARE_DYNAMIC(CXTPDateEdit) /** @endcond */ public: /** * @brief * Constructs a CXTPDateEdit object. */ CXTPDateEdit(); /** * @brief * This member function will set the time based on the text string * passed in as 'strDate'. * @param dt A reference to a COleDateTime object that represents the * date to display. */ virtual void SetDateTime(COleDateTime& dt); /** * @brief * This member function will set the time based on the text string * passed in as 'strDate'. * @param strDate A NULL-terminated string that represents the date to display. */ virtual void SetDateTime(LPCTSTR strDate); /** * @brief * This member function will retrieve a COleDateTime object that * represents the currently displayed date. * @return * A COleDateTime object representing the currently displayed date. */ virtual COleDateTime GetDateTime(); /** * @brief * This member function will retrieve a CString object that represents * the currently displayed date. * @return * A CString object representing the currently displayed date. */ virtual CString GetWindowDateTime(); /** * @brief * This member function will read the date string passed in as 'lpszData', * convert it to a COleDateTime object, and return this COleDateTime object. * @param lpszData A NULL-terminated string that represents the date to convert. * @return * A COleDateTime object that represents the converted date string. */ virtual COleDateTime ReadOleDateTime(LPCTSTR lpszData); /** * @brief * This member function is used internally to process the character passed * in by 'nChar' whose index is specified by 'nEndPos'. * @param nChar Contains the character code value of the key. * @param nEndPos Index of the character in the display string. * @return * true if successful, otherwise false. */ virtual BOOL ProcessMask(TCHAR& nChar, int nEndPos); /** * @brief * This member function will read the date passed in as 'dt', and format * the 'strData' string as DD/MM/YY. * @param strData String reference that is filled with the date. * @param dt COleDateTime object that represents the date to format. */ virtual void FormatOleDateTime(CString& strData, COleDateTime dt); }; /** * @brief * The DDX_XTPOleDateTime function manages the transfer of * integer data between a date edit control, in a dialog box, form * view, or control view object, and a COleDateTime data member of * the dialog box, form view, or control view object. * * When DDX_XTPOleDateTime is called, 'value' is set to * the current state of the date edit control. * @param pDX A pointer to a CDataExchange object. The framework supplies * this object to establish the context of the data exchange, * including its direction. * @param nIDC The resource ID of the date edit control associated with the * control property. * @param rControl A reference to a member variable of the dialog box, form * view, or control view object with which data is exchanged. * @param rDateTime A reference to a member variable of the dialog box, form * view, or control view object with which data is exchanged. * @return * @see * CXTPDateEdit */ _XTP_EXT_CLASS void AFXAPI DDX_XTPOleDateTime(CDataExchange* pDX, int nIDC, CXTPDateEdit& rControl, COleDateTime& rDateTime); /** * @brief * CXTPTimeEdit is a CXTPDateEdit derived class. It is specifically geared * toward editing time fields. */ class _XTP_EXT_CLASS CXTPTimeEdit : public CXTPDateEdit { /** @cond */ DECLARE_DYNAMIC(CXTPTimeEdit) /** @endcond */ public: /** * @brief * Constructs a CXTPTimeEdit object. */ CXTPTimeEdit(); public: /** * @brief * This member function will update the hours displayed. * @param nHours The new hours to be displayed. */ virtual void SetHours(int nHours); /** * @brief * This member function will update the minutes displayed. * @param nMins The new minutes to be displayed. */ virtual void SetMins(int nMins); /** * @brief * This member function will update the hours and minutes that are displayed * for the time edit control. * @param nHours The new hours to be displayed. * @param nMins The new minutes to be displayed. */ virtual void SetTime(int nHours, int nMins); /** * @brief * This member function will retrieve the hours displayed for the time edit * control. * @return * An integer value that represents the hours displayed. */ int GetHours() const; /** * @brief * This member function will retrieve the minutes displayed for the time * edit control. * @return * An integer value that represents the minutes displayed. */ int GetMins() const; /** * @brief * This member function is used internally to process the character * passed in by 'nChar' whose index is specified by 'nEndPos'. * @param nChar Contains the character code value of the key. * @param nEndPos Index of the character in the display string. * @return * true if successful, otherwise false. */ virtual BOOL ProcessMask(TCHAR& nChar, int nEndPos); /** * @brief * This member function will read the time passed in as 'dt', * and format the 'strData' string as HH:MM. * @param strData String reference that is filled with the time. * @param dt COleDateTime object that represents the time to format. */ virtual void FormatOleDateTime(CString& strData, COleDateTime dt); /** * @brief * Sets military time format. * @param bMilitary true to use military time. */ void SetMilitary(BOOL bMilitary = TRUE); protected: int m_iHours; /**< Represents the hours to display. */ int m_iMins; /**< Represents the minutes to display. */ BOOL m_bMilitary; /**< true if military time is used. */ }; ////////////////////////////////////////////////////////////////////// /** @cond */ AFX_INLINE int CXTPTimeEdit::GetHours() const { return m_iHours; } AFX_INLINE int CXTPTimeEdit::GetMins() const { return m_iMins; } AFX_INLINE void CXTPTimeEdit::SetMilitary(BOOL bMilitary /*= TRUE*/) { m_bMilitary = bMilitary; } /** @endcond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // #if !defined(__XTPMASKEDIT_H__) /** @endcond */