📄 amsedit.h
字号:
int m_nDigitsInGroup;
CString m_strPrefix;
double m_dMin;
double m_dMax;
private:
bool m_bAdjustingSeparators;
};
#endif // (AMSEDIT_COMPILED_CLASSES & AMSEDIT_NUMERIC_CLASS)
#if (AMSEDIT_COMPILED_CLASSES & AMSEDIT_DATE_CLASS)
// The DateBehavior class is used to allow the entry of date values.
class AMSEDIT_EXPORT DateBehavior : virtual public Behavior
{
public:
// Construction
DateBehavior(CAMSEdit* pEdit);
public:
// Operations
void SetDate(int nYear, int nMonth, int nDay);
void SetDate(const CTime& date);
void SetDate(const COleDateTime& date);
void SetDateToToday();
CTime GetDate() const;
COleDateTime GetOleDate() const;
int GetYear() const;
int GetMonth() const;
int GetDay() const;
void SetYear(int nYear);
void SetMonth(int nMonth);
void SetDay(int nDay);
virtual bool IsValid() const;
bool CheckIfValid(bool bShowErrorIfNotValid = true);
void SetRange(const CTime& dateMin, const CTime& dateMax);
void SetRange(const COleDateTime& dateMin, const COleDateTime& dateMax);
void GetRange(CTime* pDateMin, CTime* pDateMax) const;
void GetRange(COleDateTime* pDateMin, COleDateTime* pDateMax) const;
void SetSeparator(TCHAR cSep);
TCHAR GetSeparator() const;
void ShowDayBeforeMonth(bool bDayBeforeMonth = true);
bool IsDayShownBeforeMonth() const;
enum Flags
{
None = 0x0000,
DayBeforeMonth = 0x1000,
OnKillFocus_Beep_IfInvalid = 0x0001,
OnKillFocus_Beep_IfEmpty = 0x0002,
OnKillFocus_Beep = 0x0003,
OnKillFocus_SetValid_IfInvalid = 0x0004,
OnKillFocus_SetValid_IfEmpty = 0x0008,
OnKillFocus_SetValid = 0x000C,
OnKillFocus_SetFocus_IfInvalid = 0x0010,
OnKillFocus_SetFocus_IfEmpty = 0x0020,
OnKillFocus_SetFocus = 0x0030,
OnKillFocus_ShowMessage_IfInvalid = 0x0050,
OnKillFocus_ShowMessage_IfEmpty = 0x00A0,
OnKillFocus_ShowMessage = 0x00F0,
OnKillFocus_Max = 0x00FF
};
protected:
virtual CString _GetValidText() const;
virtual void _OnChar(UINT uChar, UINT nRepCnt, UINT nFlags);
virtual void _OnKeyDown(UINT uChar, UINT nRepCnt, UINT nFlags);
virtual void _OnKillFocus(CWnd* pNewWnd);
protected:
// Helpers
bool AdjustMaxMonthAndDay();
bool AdjustMaxDay();
int GetValidMonth() const;
int GetMaxMonth() const;
int GetMinMonth() const;
int GetMonthStartPosition() const;
TCHAR GetMaxMonthDigit(int nPos) const;
TCHAR GetMinMonthDigit(int nPos) const;
bool IsValidMonthDigit(TCHAR c, int nPos) const;
bool IsValidMonth(int nMonth) const;
int GetValidDay() const;
int GetMaxDay() const;
int GetMinDay() const;
int GetDayStartPosition() const;
TCHAR GetMaxDayDigit(int nPos) const;
TCHAR GetMinDayDigit(int nPos) const;
bool IsValidDayDigit(TCHAR c, int nPos) const;
bool IsValidDay(int nDay) const;
int GetValidYear() const;
int GetYearStartPosition() const;
TCHAR GetMaxYearDigit(int nPos) const;
TCHAR GetMinYearDigit(int nPos, bool bValidYear = false) const;
bool IsValidYearDigit(TCHAR c, int nPos) const;
bool IsValidYear(int nYear) const;
virtual bool IsWithinRange(const COleDateTime& date, bool bDateOnly = true) const;
virtual void ShowErrorMessage() const;
CString GetFormattedDate(int nYear, int nMonth, int nDay) const;
public:
static bool IsLeapYear(int nYear);
static CString GetString(int nValue, bool bTwoDigitWithLeadingZero = true);
static int GetMaxDayOfMonth(int nMonth, int nYear);
protected:
// Attributes
COleDateTime m_dateMin;
COleDateTime m_dateMax;
TCHAR m_cSep;
};
#endif // (AMSEDIT_COMPILED_CLASSES & AMSEDIT_DATE_CLASS)
#if (AMSEDIT_COMPILED_CLASSES & AMSEDIT_TIME_CLASS)
// The TimeBehavior class is used to allow the entry of time values.
class AMSEDIT_EXPORT TimeBehavior : virtual public Behavior
{
public:
// Construction
TimeBehavior(CAMSEdit* pEdit);
public:
// Operations
void SetTime(int nHour, int nMinute, int nSecond = 0);
void SetTime(const CTime& time);
void SetTime(const COleDateTime& time);
void SetTimeToNow();
CTime GetTime() const;
COleDateTime GetOleTime() const;
int GetHour() const;
int GetMinute() const;
int GetSecond() const;
CString GetAMPM() const;
void SetHour(int nYear);
void SetMinute(int nMonth);
void SetSecond(int nDay);
void SetAMPM(bool bAM);
virtual bool IsValid() const;
bool IsValid(bool bCheckRangeAlso) const;
bool CheckIfValid(bool bShowErrorIfNotValid = true);
void SetRange(const CTime& dateMin, const CTime& dateMax);
void SetRange(const COleDateTime& dateMin, const COleDateTime& dateMax);
void GetRange(CTime* pDateMin, CTime* pDateMax) const;
void GetRange(COleDateTime* pDateMin, COleDateTime* pDateMax) const;
void SetSeparator(TCHAR cSep);
TCHAR GetSeparator() const;
void Show24HourFormat(bool bShow24HourFormat = true);
bool IsShowing24HourFormat() const;
void ShowSeconds(bool bShowSeconds = true);
bool IsShowingSeconds() const;
void SetAMPMSymbols(const CString& strAM, const CString& strPM);
void GetAMPMSymbols(CString* pStrAM, CString* pStrPM) const;
enum Flags
{
None = 0x0000,
TwentyFourHourFormat = 0x2000,
WithSeconds = 0x4000,
OnKillFocus_Beep_IfInvalid = 0x0001,
OnKillFocus_Beep_IfEmpty = 0x0002,
OnKillFocus_Beep = 0x0003,
OnKillFocus_SetValid_IfInvalid = 0x0004,
OnKillFocus_SetValid_IfEmpty = 0x0008,
OnKillFocus_SetValid = 0x000C,
OnKillFocus_SetFocus_IfInvalid = 0x0010,
OnKillFocus_SetFocus_IfEmpty = 0x0020,
OnKillFocus_SetFocus = 0x0030,
OnKillFocus_ShowMessage_IfInvalid = 0x0050,
OnKillFocus_ShowMessage_IfEmpty = 0x00A0,
OnKillFocus_ShowMessage = 0x00F0,
OnKillFocus_Max = 0x00FF
};
protected:
virtual CString _GetValidText() const;
virtual void _OnChar(UINT uChar, UINT nRepCnt, UINT nFlags);
virtual void _OnKeyDown(UINT uChar, UINT nRepCnt, UINT nFlags);
virtual void _OnKillFocus(CWnd* pNewWnd);
protected:
// Helpers
int GetValidHour(bool b24HourFormat = false) const;
int GetMaxHour(bool b24HourFormat = false) const;
int GetMinHour(bool b24HourFormat = false) const;
int GetHourStartPosition() const;
TCHAR GetMaxHourDigit(int nPos) const;
TCHAR GetMinHourDigit(int nPos) const;
bool IsValidHourDigit(TCHAR c, int nPos) const;
bool IsValidHour(int nHour, bool b24HourFormat = false) const;
int ConvertTo24Hour(int nHour, const CString& strAMPM) const;
int ConvertToAMPMHour(int nHour, CString* pStrAMPM = NULL) const;
int GetValidMinute() const;
int GetMaxMinute() const;
int GetMinMinute() const;
int GetMaxSecond() const;
int GetMinSecond() const;
int GetMinuteStartPosition() const;
TCHAR GetMaxMinuteDigit(int nPos) const;
TCHAR GetMinMinuteDigit(int nPos) const;
bool IsValidMinuteDigit(TCHAR c, int nPos) const;
bool IsValidMinute(int nMinute) const;
int GetValidSecond() const;
int GetSecondStartPosition() const;
TCHAR GetMaxSecondDigit(int nPos) const;
TCHAR GetMinSecondDigit(int nPos) const;
bool IsValidSecondDigit(TCHAR c, int nPos) const;
bool IsValidSecond(int nSecond) const;
void ShowAMPM();
bool ChangeAMPM(TCHAR c);
CString GetValidAMPM() const;
int GetAMPMStartPosition() const;
bool IsValidAMPM(const CString& strAMPM) const;
int GetAMPMPosition(const CString& strText) const;
virtual bool IsWithinRange(const COleDateTime& date, bool bDateOnly = true) const;
virtual void ShowErrorMessage() const;
CString GetFormattedTime(int nHour, int nMinute, int nSecond, const CString& strAMPM = _T("")) const;
void AdjustWithinRange();
protected:
// Attributes
COleDateTime m_timeMin;
COleDateTime m_timeMax;
TCHAR m_cSep;
CString m_strAM;
CString m_strPM;
int m_nAMPMLength;
int m_nHourStart;
};
#endif // (AMSEDIT_COMPILED_CLASSES & AMSEDIT_TIME_CLASS)
#if (AMSEDIT_COMPILED_CLASSES & AMSEDIT_DATETIME_CLASS) == AMSEDIT_DATETIME_CLASS
// The DateTimeBehavior class is used to allow the entry of date and time values.
class AMSEDIT_EXPORT DateTimeBehavior : public DateBehavior,
public TimeBehavior
{
public:
// Construction
DateTimeBehavior(CAMSEdit* pEdit);
void SetDateTime(int nYear, int nMonth, int nDay, int nHour, int nMinute, int nSecond = 0);
void SetDateTime(const CTime& dt);
void SetDateTime(const COleDateTime& dt);
void SetToNow();
CTime GetDateTime() const;
COleDateTime GetOleDateTime() const;
virtual bool IsValid() const;
void SetRange(const CTime& dateMin, const CTime& dateMax);
void SetRange(const COleDateTime& dateMin, const COleDateTime& dateMax);
void GetRange(CTime* pDateMin, CTime* pDateMax) const;
void GetRange(COleDateTime* pDateMin, COleDateTime* pDateMax) const;
void SetSeparator(TCHAR cSep, bool bDate);
TCHAR GetSeparator(bool bDate) const;
bool ModifyFlags(UINT uAdd, UINT uRemove);
enum Flags
{
DateOnly = 0x0100,
TimeOnly = 0x0200,
OnKillFocus_Beep_IfInvalid = 0x0001,
OnKillFocus_Beep_IfEmpty = 0x0002,
OnKillFocus_Beep = 0x0003,
OnKillFocus_SetValid_IfInvalid = 0x0004,
OnKillFocus_SetValid_IfEmpty = 0x0008,
OnKillFocus_SetValid = 0x000C,
OnKillFocus_SetFocus_IfInvalid = 0x0010,
OnKillFocus_SetFocus_IfEmpty = 0x0020,
OnKillFocus_SetFocus = 0x0030,
OnKillFocus_ShowMessage_IfInvalid = 0x0050,
OnKillFocus_ShowMessage_IfEmpty = 0x00A0,
OnKillFocus_ShowMessage = 0x00F0,
OnKillFocus_Max = 0x00FF
};
protected:
virtual CString _GetValidText() const;
virtual void _OnChar(UINT uChar, UINT nRepCnt, UINT nFlags);
virtual void _OnKeyDown(UINT uChar, UINT nRepCnt, UINT nFlags);
virtual void _OnKillFocus(CWnd* pNewWnd);
protected:
virtual bool IsWithinRange(const COleDateTime& date, bool bDateOnly = true) const;
virtual void ShowErrorMessage() const;
};
#endif // (AMSEDIT_COMPILED_CLASSES & AMSEDIT_DATETIME_CLASS) == AMSEDIT_DATETIME_CLASS
// Generated message map functions (for CAMSEdit)
protected:
//{{AFX_MSG(CAMSEdit)
//}}AFX_MSG
afx_msg LRESULT OnCut(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnPaste(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnClear(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
};
#if (AMSEDIT_COMPILED_CLASSES & AMSEDIT_ALPHANUMERIC_CLASS)
/////////////////////////////////////////////////////////////////////////////
// CAMSAlphanumericEdit window
// The CAMSAlphanumericEdit is a CAMSEdit control which supports the AlphanumericBehavior class.
//
class AMSEDIT_EXPORT CAMSAlphanumericEdit : public CAMSEdit,
public CAMSEdit::AlphanumericBehavior
{
public:
// Construction
CAMSAlphanumericEdit(int nMaxChars = 0, const CString& strInvalidChars = _T("%'*\"+?><:\\"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -