SECCurrencyEdit Class
class SECCurrencyEdit: public SECDropEdit public CWnd
The SECCurrencyEdit provides an extensible class for entering and displaying custom-formatted currency data. Input data parsing and output display formatting can be customized by descending new classes from SECCurrencyEdit::Format and SECCurrencyEdit.
The SECCurrencyEdit class supports some of the EM_* edit control message interface, and it can thus be manipulated to some degree using a Cedit object (not recommended, but possible if required for compatibility with existing code). Messages supported are listed below.
See the CURRENCY sample in the \SAMPLES\TOOLKIT\STANDARD\CONTROLS\CURRENCY directory for a demonstration of this class.
Defined in: curredit.h
Windows Messages
WM_COPY, WM_CUT, WM_GETFONT, WM_PASTE, WM_SETFONT, WM_SETREDRAW, WM_SETTEXT, WM_UNDO,
Edit Control Messages
EM_CANUNDO, EM_EMPTYUNDOBUFFER, EM_GETSEL, EM_SETREADONLY EM_SETSEL, EM_UNDO, EM_SETMARGINS
Class Members
Construction/destruction
Constructs a SECCurrencyEdit object.
SECCurrencyEdit(Format* pFmt)
Constructs a SECCurrencyEdit object.
BOOL Initialize(CWnd* pwndParent, UINT uiControlID)
Replaces an existing edit control.
Attributes
void GetValue(double& d) const
Gets the actual numeric value directly.
void SetValue(double d, BOOL bRedraw = TRUE)
Sets the actual numeric value directly.
void GetFormat(Format& f)
Gets the display formatting data.
void SetFormat(const Format& f)
Sets the display formatting data.
enum Align
Alignments
Align GetAlignment() const
The alignment is actually maintained via edit control
void SetAlignment(Align a)
The alignment is actually maintained via edit control
BOOL IsReadOnly() const
The read-only feature is actually maintained via the normal
void SetReadOnly(BOOL b)
The read-only feature is actually maintained via the normal
void SetMargins(UINT nLeft, UINT nRight)
Sets the margins for the control.
DWORD GetMargins() const
Retrieves the margins for the control.
Overridable
virtual BOOL HitTestBtn(CPoint point, BOOL bClient = FALSE) const
Performs hit testing for the button.
virtual BOOL PrepareTextForPaste(CString& strText)
Pre-paste processing.
virtual CMenu* CreatePopupMenu() const
Creates the popup menu.
virtual void DeletePopupMenu(CMenu* p) const
Deletes the popup menu.
virtual void DoBackspace()
Processes backspace key press.
virtual void DoDelete()
Processes delete key press.
virtual void DoInsert(LPCTSTR pcsz)
Processes insert key press.
virtual void EraseBackground(CDC* pDC)
Erases the control background.
virtual void SaveDataForUndo(LPCTSTR p = NULL, int iCaret = -1)
Stores data for undo operation.
virtual void StartEdit(int iCaretPos)
Begins edit mode.
virtual void StopEdit()
Ends edit mode.
virtual void DrawDecimalSeparatorLine(CDC& DC, int x)
Draws a vertical decimal separator on the control.
virtual void HandleNegativeSignKey()
Handles a minus sign key press.
virtual void ToggleOverstrikeMode()
Toggles overstrike mode state.
virtual BOOL ShowCalculator()
Displays calculator.
virtual void OnClicked()
Method called when the button has been clicked.
Implementation
void NotifyParent(UINT uiCode)
Notify parent of control state change.
BOOL IsNegative() const
Determines if current value is negative.
BOOL HasSel() const
Detemines if edit control has highlighted (selected) text.
BOOL SetSel(int iStart, int iStop)
Sets the selected text.
BOOL SetSelNone()
Deselects all text in the control.
BOOL SetSelAll()
Selects all text in the control
BOOL IsMouseSelecting() const
Returns whether text is currently being selected with the mouse.
BOOL IsEntireNumberSelected(BOOL* pbMore = NULL) const
Returns whether the entire number is selected.
BOOL IsOverstrikeEnabled() const
Returns whether overstrike mode is enabled.
COLORREF GetBackgroundColor() const
Returns the background color of the edit control.
COLORREF GetTextColor() const
Returns the text color for the edit control.
int PointToCaretPos(const CPoint& pt)
Points to the caret’s position.
void CalculateTextRect(CRect& rc)
Calculates the rectangle for text in the edit control.
void DoInsert(TCHAR c)
Makes an insertion in the edit control.
void GetSelectedText(CString& s) const
Gets text selected in the edit control.
void MoveCaret(int iChar, BOOL bUpdateSel = FALSE)
Relocates the caret in the edit control.
void PaintingCore(CDC& DC)
Redraws the core currency formatting on the specified display device context.
void QueueRedraw(BOOL bEraseBackground = TRUE)
Redraws queued data.
void ReplaceSelString(LPCTSTR pcszNew, CString& str)
Replaces the currently selected string with the specified text.
void SetWindowTextNoParse(LPCTSTR p)
Sets text that does not require parsing.
void MoveCaretToNumber()
Positions the caret near the number.
void SetValue(double d, BOOL bNegative, BOOL bRedraw)
Sets the value of the number in the control.
Protected data members
BOOL m_bNegative
Is the data value negative?
BOOL m_bCanUndo
Undo buffer has something?
BOOL m_bParseOnSetText
Parse value on WM_SETTEXT?
BOOL m_bRedraw
Is redraw allowed?
BOOL m_bMouseSelect
Are we mouse selecting?
BOOL m_bOverstrike
Is overstrike mode enabled?
UNDODATA m_Undo
Undo buffer
double m_dValue
Numeric value
Format* m_pFormat
Current format settings
HFONT m_hFont
Font set via WM_SETFONT
int m_iCaretPos
Caret character position
SELDATA m_Sel
Selection information
UINT m_uiRightMargin
The right margin in pixels.
UINT m_uiLeftMargin
The left margin in pixels.