WTL Controls
Back to the WTL Controls Home Page.
ODStatic.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 
20  //----------------------------------------------------------------------------------------------
82  class CODStatic :
83  public CWindowImpl<CODStatic, CStatic>,
84  public COwnerDraw<CODStatic>,
85  public CThemeImpl<CODStatic>
86  {
87 
88  public:
89 
91  DECLARE_WND_SUPERCLASS(_T("CODStatic"), CStatic::GetWndClassName())
92 
93 
94 
95  CODStatic() noexcept;
96  virtual ~CODStatic();
97 
98  void SubclassStatic(HWND hWnd);
99  void UnSubclassStatic();
100 
101 
102  void SetBtnFaceBkgnd(bool value);
103  bool GetBtnFaceBkgnd() const;
104 
105  void SetBackColor(COLORREF value);
106  COLORREF GetBackColor() const;
107 
108  void SetTextColor(COLORREF value);
109  COLORREF GetTextColor() const;
110 
111  void SetCaption(LPCTSTR text);
112  std::basic_string<TCHAR> GetCaption() const;
113 
114  void SetMultilineEnabled(bool value);
115  bool GetMultilineEnabled() const;
116 
117  void SetEndEllipsisEnabled(bool value);
118  bool GetEndEllipsisEnabled() const;
119 
120  void SetPathEllipsisEnabled(bool value);
121  bool GetPathEllipsisEnabled() const;
122 
125 
128 
129  void SetEdgeStyle(CEdgeStyle style);
130  CEdgeStyle GetEdgeStyle() const;
131 
132  void SetVerticalMargin(int margin);
133  int GetVerticalMargin() const;
134 
135  void SetHorizontalMargin(int margin);
136  int GetHorizontalMargin() const;
137 
138  void UseThemedStyle(bool val);
139  bool IsUsingThemedStyle() const;
140 
143 
146 
147  void UpdateContent();
148 
149 
151  BOOL OnEraseBkgnd(CDCHandle dc);
152  void DrawItem(LPDRAWITEMSTRUCT lp);
153  void OnSysColorChange();
155 
156  private:
157 
158  UINT GetTextFormat();
159  void UpdateBackBrush();
160 
161  int GetVertEdgeWidth();
162  int GetHorzEdgeHeight();
163  int GetEdgeOffset(int metric);
164 
165  void PrepareGDIStuff();
166  void DestroyGDIStuff();
167 
168  void DrawEdge(CRect r);
169 
170  CString m_Text;
171  bool m_bMultiLine;
172  bool m_bEndEllipsis;
173  bool m_bPathEllipsis;
174  CVertAlignment m_vaVertAlign;
175  CHorzAlignment m_haHorzAlign;
176 
177  int m_iHorzMargin;
178  int m_iVertMargin;
179 
180  COLORREF m_clrBackColor;
181  COLORREF m_clrTextColor;
182 
183  bool m_bUseTheme;
184  CThemedBackgroundStyle m_ThemedBackStyle;
185  CThemedTextStyle m_ThemedTextStyle;
186 
187  CEdgeStyle m_EdgeStyle;
188 
189  bool m_bBtnFaceBkgnd;
190  bool m_bDirtyColor;
191  bool m_bUpdateContent;
192 
193  HBRUSH m_hbrBackBrush;
194  HBITMAP m_hOldMap;
195  CImage m_hCanvas;
196  HDC m_hMemDC;
197 
198  BEGIN_MSG_MAP_EX(CODStatic)
199  CHAIN_MSG_MAP(CThemeImpl<CODStatic>)
200  MSG_WM_SYSCOLORCHANGE(OnSysColorChange)
201  MSG_WM_THEMECHANGED(OnSysColorChange)
202  MSG_WM_ERASEBKGND(OnEraseBkgnd)
203  CHAIN_MSG_MAP_ALT(COwnerDraw<CODStatic>, 1)
204  DEFAULT_REFLECTION_HANDLER()
205  END_MSG_MAP()
206 
207  };
208  //----------------------------------------------------------------------------------------------
209 };
void SetEdgeStyle(CEdgeStyle style)
The EdgeStyle state determines the type of graphic boundary indicator surrounding the control in it&#39;s...
Definition: ODStatic.cpp:477
void SetHorzTextAlignment(CHorzAlignment value)
The CHorzAlignment member variable state will result in either the DT_CENTER, DT_LEFT or DT_RIGHT fla...
Definition: ODStatic.cpp:407
void SetVerticalMargin(int margin)
Sets top and bottom text margin inside window edge. A call to UpdateContent may be required to make c...
Definition: ODStatic.cpp:508
COLORREF GetBackColor() const
Default: COLOR_BTNFACE.
Definition: ODStatic.cpp:192
COLORREF GetTextColor() const
Default: COLOR_WINDOWTEXT.
Definition: ODStatic.cpp:225
int GetVerticalMargin() const
Default: 0.
Definition: ODStatic.cpp:494
bool GetMultilineEnabled() const
Default: false.
Definition: ODStatic.cpp:291
void SetCaption(LPCTSTR text)
Set a new string to display. A call to UpdateContent may be required to make the new caption visible...
Definition: ODStatic.cpp:274
void SetMultilineEnabled(bool value)
If false, the DT_SINGLELINE flag will be included in calls to DrawText (or DrawThemeText). A call to UpdateContent may be required to make changes visible.
Definition: ODStatic.cpp:307
CEdgeStyle
Style of edge defining control boundaries.
Definition: WTL_Controls.h:37
void SetBtnFaceBkgnd(bool value)
Set or clear the UseBtnFaceBkgnd state. A call to UpdateContent may be required to make the new state...
Definition: ODStatic.cpp:175
CVertAlignment GetVertTextAlignment() const
Default: CVertAlignment::vaLeft.
Definition: ODStatic.cpp:425
CVertAlignment
Control vertical placement of text in control window.
Definition: WTL_Controls.h:47
CHorzAlignment GetHorzTextAlignment() const
Default: CHorzAlignment::haMiddle.
Definition: ODStatic.cpp:390
void SetVertTextAlignment(CVertAlignment value)
The CVertAlignment member variable state will result in either the DT_BOTTOM, DT_TOP or DT_VCENTER fl...
Definition: ODStatic.cpp:442
bool GetPathEllipsisEnabled() const
Default: false.
Definition: ODStatic.cpp:357
An owner-drawn CStatic descendant, providing custom background and text colors and edge styles...
Definition: ODStatic.h:82
void SetTextColor(COLORREF value)
Set a new text color. A call to UpdateContent may be required to make the new color visible...
Definition: ODStatic.cpp:240
CThemedBackgroundStyle GetThemedBackgroundStyle() const
Default: tbMainInstructionPane.
Definition: ODStatic.cpp:587
void SetThemedTextStyle(CThemedTextStyle val)
Set the ThemedTextStyle to a new value.
Definition: ODStatic.cpp:677
void SetThemedBackgroundStyle(CThemedBackgroundStyle val)
Set the ThemedBackgroundStyle to a new value.
Definition: ODStatic.cpp:620
int GetHorizontalMargin() const
Default: 0.
Definition: ODStatic.cpp:525
void UseThemedStyle(bool val)
If true, content will be painted using DrawThemeBackground and DrawThemeText, rather than the older F...
Definition: ODStatic.cpp:570
CEdgeStyle GetEdgeStyle() const
Default: CEdgeStyle::esLine.
Definition: ODStatic.cpp:459
void SetHorizontalMargin(int margin)
Sets left and right text margin inside window edge. A call to UpdateContent may be required to make c...
Definition: ODStatic.cpp:539
void UpdateContent()
Wraps calls to Invalidate and UpdateWindow, forcing a repaint, updating the back buffer and blitting ...
Definition: ODStatic.cpp:693
CHorzAlignment
Control horizontal placement of text in control window.
Definition: WTL_Controls.h:42
void SetBackColor(COLORREF value)
Set a new background color. A call to UpdateContent may be required to make the new color visible...
Definition: ODStatic.cpp:207
bool GetEndEllipsisEnabled() const
Default: false.
Definition: ODStatic.cpp:324
void SetEndEllipsisEnabled(bool value)
If true, the DT_END_ELLIPSIS flag will be included in calls to DrawText (or DrawThemeText). A call to UpdateContent may be required to make changes visible.
Definition: ODStatic.cpp:340
CThemedBackgroundStyle
The CThemedBackgroundStyle enumerants correspond to select TaskDialog Parts, as indicated below...
Definition: WTL_Controls.h:67
void UnSubclassStatic()
Un-subclass the window and release GDI resources.
Definition: ODStatic.cpp:129
void SubclassStatic(HWND hWnd)
Subclass a Static Text control.
Definition: ODStatic.cpp:86
std::basic_string< TCHAR > GetCaption() const
Default: "".
Definition: ODStatic.cpp:258
void SetPathEllipsisEnabled(bool value)
If true, the DT_PATH_ELLIPSIS flag will be included in calls to DrawText (or DrawThemeText). A call to UpdateContent may be required to make changes visible.
Definition: ODStatic.cpp:373
CThemedTextStyle GetThemedTextStyle() const
Default: ttMainInstruction.
Definition: ODStatic.cpp:637
bool GetBtnFaceBkgnd() const
Default: false.
Definition: ODStatic.cpp:152
CThemedTextStyle
The CThemedTextStyle enumerants correspond to select TextStyle Parts and States, as indicated below...
Definition: WTL_Controls.h:94
bool IsUsingThemedStyle() const
Default: false.
Definition: ODStatic.cpp:556