WTL Controls
Back to the WTL Controls Home Page.
EditPlus.h
Go to the documentation of this file.
1 #pragma once
2 #include "stdafx.h"
3 //--------------------------------------------------------------------------------------
4 //--------------------------------------------------------------------------------------
5 //
6 //
7 // WTL Control Library
8 // by
9 // Bright Ideas Software®
10 // Copyright © 2018 by Bright Ideas Software.
11 //
12 //
13 //
14 //--------------------------------------------------------------------------------------
15 //--------------------------------------------------------------------------------------
16 
17 namespace BIS_WTL_CONTROLS
18 {
19 
46  class CEditPlus : public CWindowImpl<CEditPlus, CEdit>
47  {
48 
49  public:
50 
52  DECLARE_WND_SUPERCLASS(_T("CEditPlus"), CEdit::GetWndClassName())
53 
54 
55  CEditPlus() noexcept;
56  virtual ~CEditPlus();
57 
58  void SubclassEdit(HWND hWnd);
59  void UnSubclassEdit();
60 
61 
62  void SetBackColor(COLORREF value);
63  COLORREF GetBackColor() const;
64 
65  void SetTextColor(COLORREF value);
66  COLORREF GetTextColor() const;
67 
68  void SetFocusedBackColor(COLORREF value);
69  COLORREF GetFocusedBackColor() const;
70 
71  void SetFocusedTextColor(COLORREF value);
72  COLORREF GetFocusedTextColor() const;
73 
74  void EnableFloatingPointMode(bool enabled);
75  bool IsFloatingPointModeEnabled() const;
76 
77  void EnableNotifyOnCR(bool value);
78  bool IsNotifyOnCREnabled() const;
79 
80  private:
81 
82 
83  COLORREF m_BackColor;
84  COLORREF m_TextColor;
85  COLORREF m_FocusedBackColor;
86  COLORREF m_FocusedTextColor;
87  HBRUSH m_BackBrush;
88  HBRUSH m_FocusedBackBrush;
89 
90  bool m_bFloatingPointMode;
91  bool m_bNotifyOnCR;
92 
93  void UpdateBackBrushes();
94  void DeleteBrushes();
95 
96 
97  void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
98  BOOL OnEraseBkgnd(CDCHandle dc);
99  LRESULT OnCtlColor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
100 
101 
102  BEGIN_MSG_MAP_EX(CEditPlus)
103  MSG_WM_CHAR(OnChar)
104  MSG_WM_ERASEBKGND(OnEraseBkgnd)
105  MESSAGE_HANDLER(OCM_CTLCOLORSTATIC, OnCtlColor)
106  MESSAGE_HANDLER(OCM_CTLCOLOREDIT, OnCtlColor)
107  DEFAULT_REFLECTION_HANDLER()
108  END_MSG_MAP()
109 
110  };
111 };
void EnableFloatingPointMode(bool enabled)
Change the Floating Point Mode state.
Definition: EditPlus.cpp:224
COLORREF GetFocusedBackColor() const
Default: COLOR_WINDOW.
Definition: EditPlus.cpp:148
void UnSubclassEdit()
Un-subclass the window and release GDI resources.
Definition: EditPlus.cpp:70
void SetFocusedTextColor(COLORREF value)
Select a new text color used when the control has focus.
Definition: EditPlus.cpp:196
void SetTextColor(COLORREF value)
Select a new text color used when the control does not have focus.
Definition: EditPlus.cpp:134
bool IsNotifyOnCREnabled() const
Default: true.
Definition: EditPlus.cpp:240
void SetFocusedBackColor(COLORREF value)
Select a new background color used when the control has focus.
Definition: EditPlus.cpp:162
void EnableNotifyOnCR(bool value)
Change the &#39;Notify on CR&#39; state.
Definition: EditPlus.cpp:253
COLORREF GetBackColor() const
Default: COLOR_WINDOW.
Definition: EditPlus.cpp:86
COLORREF GetTextColor() const
Default: COLOR_WINDOWTEXT.
Definition: EditPlus.cpp:119
void SetBackColor(COLORREF value)
Select a new background color used when the control does not have focus.
Definition: EditPlus.cpp:100
void SubclassEdit(HWND hWnd)
Subclass an edit control and create GDI objects.
Definition: EditPlus.cpp:57
A CEdit descendant, providing custom focused and non-focused colors via WM_CTLCOLOR variants...
Definition: EditPlus.h:46
bool IsFloatingPointModeEnabled() const
Default: false.
Definition: EditPlus.cpp:209
COLORREF GetFocusedTextColor() const
Default: CLR_RED.
Definition: EditPlus.cpp:181