25 m_bBtnFaceBkgnd =
false;
26 m_clrTextColor = ::GetSysColor (COLOR_WINDOWTEXT);
27 m_clrBackColor = ::GetSysColor (COLOR_BTNFACE);
30 m_bEndEllipsis =
false;
31 m_bPathEllipsis =
false;
46 m_bUpdateContent =
true;
47 m_hbrBackBrush = NULL;
50 SetThemeClassList(CA2W(
"TEXTSTYLE;TASKDIALOG"));
52 SetThemeClassList(_T(
"TEXTSTYLE;TASKDIALOG"));
60 ATLASSERT(m_hWnd == NULL);
64 if (m_hbrBackBrush != NULL)
66 ::DeleteObject (m_hbrBackBrush);
67 m_hbrBackBrush = NULL;
88 CWindowImpl<CODStatic, CStatic>::SubclassWindow(hWnd);
90 DWORD style = GetStyle();
91 DWORD exstyle = GetExStyle();
93 if (style & SS_CENTER)
95 else if ((style & SS_RIGHT) ||(exstyle & WS_EX_RIGHT))
100 if (style & SS_LEFTNOWORDWRAP)
102 m_bMultiLine =
false;
106 if (style & SS_ENDELLIPSIS)
108 m_bMultiLine =
false;
110 m_bEndEllipsis =
true;
113 m_bEndEllipsis =
false;
115 GetWindowText(m_Text);
119 ModifyStyle(0, SS_NOTIFY | SS_OWNERDRAW);
133 if (m_hbrBackBrush != NULL)
135 ::DeleteObject (m_hbrBackBrush);
136 m_hbrBackBrush = NULL;
154 return(m_bBtnFaceBkgnd);
177 if (m_bBtnFaceBkgnd != value)
179 m_bDirtyColor =
true;
180 m_bBtnFaceBkgnd = value;
194 return(m_clrBackColor);
209 if (m_clrBackColor != value)
211 m_bDirtyColor =
true;
212 m_clrBackColor = value;
227 return(m_clrTextColor);
242 if (m_clrTextColor != value)
244 m_bUpdateContent =
true;
245 m_clrTextColor = value;
260 return((LPCTSTR)m_Text);
276 if (m_Text.Compare(text) != 0)
279 m_bUpdateContent =
true;
293 return(m_bMultiLine);
309 if (m_bMultiLine != value)
311 m_bMultiLine = value;
312 m_bUpdateContent =
true;
326 return(m_bEndEllipsis);
342 if (m_bEndEllipsis != value)
344 m_bEndEllipsis = value;
345 m_bUpdateContent =
true;
359 return(m_bPathEllipsis);
375 if (m_bPathEllipsis != value)
377 m_bPathEllipsis = value;
378 m_bUpdateContent =
true;
392 return(m_haHorzAlign);
409 if (m_haHorzAlign != value)
411 m_haHorzAlign = value;
412 m_bUpdateContent =
true;
427 return(m_vaVertAlign);
444 if (m_vaVertAlign != value)
446 m_vaVertAlign = value;
447 m_bUpdateContent =
true;
479 if (m_EdgeStyle != style)
482 m_bUpdateContent =
true;
496 return(m_iVertMargin);
510 if ((margin >= 0)&&(m_iVertMargin != margin))
512 m_iVertMargin = margin;
513 m_bUpdateContent =
true;
527 return(m_iHorzMargin);
541 if ((margin >= 0)&&(m_iHorzMargin != margin))
543 m_iHorzMargin = margin;
544 m_bUpdateContent =
true;
572 if (m_bUseTheme != val)
575 m_bUpdateContent =
true;
589 return(m_ThemedBackStyle);
622 if (val != m_ThemedBackStyle)
624 m_ThemedBackStyle = val;
625 m_bUpdateContent =
true;
639 return(m_ThemedTextStyle);
679 if (m_ThemedTextStyle != val)
681 m_ThemedTextStyle = val;
682 m_bUpdateContent =
true;
695 m_bUpdateContent =
true;
706 int CODStatic::GetEdgeOffset(
int metric)
725 retval = ::GetSystemMetrics(metric);
732 int CODStatic::GetHorzEdgeHeight()
734 return (GetEdgeOffset(SM_CXEDGE));
737 int CODStatic::GetVertEdgeWidth()
739 return (GetEdgeOffset(SM_CYEDGE));
743 void CODStatic::PrepareGDIStuff()
752 if ((r.Width() > 0)&&(r.Height() > 0))
754 m_hCanvas.Create(r.Width(), r.Height(), 24, 0);
756 if (! m_hCanvas.IsNull())
759 HDC dc = ::GetDC(m_hWnd);
760 m_hMemDC = ::CreateCompatibleDC(dc);
762 if (m_hMemDC != NULL)
763 m_hOldMap = (HBITMAP)::SelectObject(m_hMemDC, (HBITMAP)m_hCanvas);
767 ::ReleaseDC(m_hWnd, dc);
768 m_bUpdateContent =
true;
774 void CODStatic::DestroyGDIStuff()
777 if (m_hMemDC != NULL)
779 if (! m_hCanvas.IsNull())
781 ::SelectObject(m_hMemDC, m_hOldMap);
786 ::DeleteDC(m_hMemDC);
793 UINT CODStatic::GetTextFormat()
795 UINT format = DT_EDITCONTROL;
797 switch (m_haHorzAlign)
810 switch (m_vaVertAlign)
816 format |= DT_VCENTER;
823 if (m_bMultiLine ==
true)
824 format = format |DT_WORDBREAK ;
826 format = format | DT_SINGLELINE ;
828 if (m_bEndEllipsis ==
true)
829 format = format | DT_END_ELLIPSIS;
831 if (m_bPathEllipsis ==
true)
832 format = format | DT_PATH_ELLIPSIS;
840 void CODStatic::DrawEdge(CRect r)
851 ::DrawEdge(m_hMemDC, r, EDGE_BUMP,BF_RECT );
854 ::DrawEdge(m_hMemDC, r, EDGE_ETCHED,BF_RECT );
857 ::DrawEdge(m_hMemDC, r, EDGE_RAISED,BF_RECT );
860 ::DrawEdge(m_hMemDC, r, EDGE_SUNKEN,BF_RECT);
863 ::DrawEdge(m_hMemDC, r, BDR_RAISEDOUTER,BF_RECT );
866 ::DrawEdge(m_hMemDC, r, BDR_SUNKENOUTER,BF_RECT);
871 void CODStatic::UpdateBackBrush()
873 m_bDirtyColor =
false;
875 if (m_hbrBackBrush != NULL)
877 ::DeleteObject (m_hbrBackBrush);
878 m_hbrBackBrush = NULL;
881 if (m_bBtnFaceBkgnd ==
false)
882 m_hbrBackBrush = ::CreateSolidBrush (m_clrBackColor);
884 m_bUpdateContent =
true;
894 BOOL CODStatic::OnEraseBkgnd(CDCHandle dc)
899 void CODStatic::OnSysColorChange()
901 if (m_bBtnFaceBkgnd ==
true)
905 void CODStatic::DrawItem(LPDRAWITEMSTRUCT lp)
913 if (m_bDirtyColor ==
true)
919 GetClientRect(&rect);
921 if ((m_hMemDC == NULL)||( m_hCanvas.IsNull()))
924 if ((m_hMemDC != NULL)&&( ! m_hCanvas.IsNull()))
927 if ((rect.Width() != m_hCanvas.GetWidth())||(rect.Height() != m_hCanvas.GetHeight()))
930 if (m_bUpdateContent ==
true)
933 m_bUpdateContent =
false;
935 if ((IsThemeNull())||(m_bUseTheme ==
false))
937 if (m_bBtnFaceBkgnd ==
false)
939 ::FillRect(m_hMemDC, rect, m_hbrBackBrush);
940 ::SetBkColor(m_hMemDC, m_clrBackColor);
944 ::FillRect(m_hMemDC, rect, ::GetSysColorBrush(COLOR_BTNFACE));
945 ::SetBkColor(m_hMemDC, ::GetSysColor(COLOR_BTNFACE));
948 if (IsWindowEnabled())
951 ::SetTextColor(m_hMemDC, ::GetSysColor(COLOR_GRAYTEXT));
955 UINT task_dialog_part = 0;
956 switch(m_ThemedBackStyle)
959 task_dialog_part = TDLG_PRIMARYPANEL;
963 task_dialog_part = TDLG_MAININSTRUCTIONPANE;
967 task_dialog_part = TDLG_CONTENTPANE;
971 task_dialog_part = TDLG_SECONDARYPANEL;
975 task_dialog_part = TDLG_CONTROLPANE;
978 DrawThemeBackground(m_hMemDC, task_dialog_part, 0, rect);
981 UINT format = GetTextFormat();
984 text_rect.CopyRect(&rect);
986 int border_height = GetHorzEdgeHeight();
987 int border_width = GetVertEdgeWidth();
988 text_rect.DeflateRect(border_width, border_height, border_width, border_height);
989 text_rect.DeflateRect(m_iHorzMargin, m_iVertMargin, m_iHorzMargin, m_iVertMargin);
991 if ((IsThemeNull())||(m_bUseTheme ==
false))
993 oldfont = (HFONT)::SelectObject(m_hMemDC, cfont);
994 ::DrawText(m_hMemDC, m_Text, m_Text.GetLength(), text_rect, format);
995 ::SelectObject(m_hMemDC, oldfont);
1001 UINT text_state = 0;
1003 switch (m_ThemedTextStyle)
1006 text_part = TEXT_MAININSTRUCTION;
1010 text_part = TEXT_INSTRUCTION;
1014 text_part = TEXT_BODYTITLE;
1018 text_part = TEXT_BODYTEXT;
1022 text_part = TEXT_SECONDARYTEXT;
1026 text_part = TEXT_LABEL;
1030 text_part = TEXT_CONTROLLABEL;
1031 text_state = TS_CONTROLLABEL_NORMAL;
1035 text_part = TEXT_CONTROLLABEL;
1036 text_state = TS_CONTROLLABEL_DISABLED;
1041 DrawThemeText(m_hMemDC, text_part ,text_state, CA2W(m_Text), m_Text.GetLength(), format, 0, text_rect);
1043 DrawThemeText(m_hMemDC, text_part, text_state, m_Text, m_Text.GetLength(), format, 0, text_rect);
1051 ::BitBlt (dc, 0, 0,rect.Width (), rect.Height (), m_hMemDC, 0, 0, SRCCOPY);
void SetEdgeStyle(CEdgeStyle style)
The EdgeStyle state determines the type of graphic boundary indicator surrounding the control in it's...
void SetHorzTextAlignment(CHorzAlignment value)
The CHorzAlignment member variable state will result in either the DT_CENTER, DT_LEFT or DT_RIGHT fla...
void SetVerticalMargin(int margin)
Sets top and bottom text margin inside window edge. A call to UpdateContent may be required to make c...
COLORREF GetBackColor() const
Default: COLOR_BTNFACE.
COLORREF GetTextColor() const
Default: COLOR_WINDOWTEXT.
int GetVerticalMargin() const
Default: 0.
bool GetMultilineEnabled() const
Default: false.
void SetCaption(LPCTSTR text)
Set a new string to display. A call to UpdateContent may be required to make the new caption visible...
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.
CEdgeStyle
Style of edge defining control boundaries.
void SetBtnFaceBkgnd(bool value)
Set or clear the UseBtnFaceBkgnd state. A call to UpdateContent may be required to make the new state...
CVertAlignment GetVertTextAlignment() const
Default: CVertAlignment::vaLeft.
CVertAlignment
Control vertical placement of text in control window.
CHorzAlignment GetHorzTextAlignment() const
Default: CHorzAlignment::haMiddle.
BOOL OutlineRect(HDC HDestDC, const RECT &RDest)
Draw a rectangular outline with the current pen.
void SetVertTextAlignment(CVertAlignment value)
The CVertAlignment member variable state will result in either the DT_BOTTOM, DT_TOP or DT_VCENTER fl...
bool GetPathEllipsisEnabled() const
Default: false.
void SetTextColor(COLORREF value)
Set a new text color. A call to UpdateContent may be required to make the new color visible...
CThemedBackgroundStyle GetThemedBackgroundStyle() const
Default: tbMainInstructionPane.
void SetThemedTextStyle(CThemedTextStyle val)
Set the ThemedTextStyle to a new value.
void SetThemedBackgroundStyle(CThemedBackgroundStyle val)
Set the ThemedBackgroundStyle to a new value.
int GetHorizontalMargin() const
Default: 0.
void UseThemedStyle(bool val)
If true, content will be painted using DrawThemeBackground and DrawThemeText, rather than the older F...
CEdgeStyle GetEdgeStyle() const
Default: CEdgeStyle::esLine.
void SetHorizontalMargin(int margin)
Sets left and right text margin inside window edge. A call to UpdateContent may be required to make c...
void UpdateContent()
Wraps calls to Invalidate and UpdateWindow, forcing a repaint, updating the back buffer and blitting ...
CHorzAlignment
Control horizontal placement of text in control window.
void SetBackColor(COLORREF value)
Set a new background color. A call to UpdateContent may be required to make the new color visible...
bool GetEndEllipsisEnabled() const
Default: false.
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.
CThemedBackgroundStyle
The CThemedBackgroundStyle enumerants correspond to select TaskDialog Parts, as indicated below...
void UnSubclassStatic()
Un-subclass the window and release GDI resources.
void SubclassStatic(HWND hWnd)
Subclass a Static Text control.
std::basic_string< TCHAR > GetCaption() const
Default: "".
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.
CThemedTextStyle GetThemedTextStyle() const
Default: ttMainInstruction.
bool GetBtnFaceBkgnd() const
Default: false.
CThemedTextStyle
The CThemedTextStyle enumerants correspond to select TextStyle Parts and States, as indicated below...
bool IsUsingThemedStyle() const
Default: false.