1 /********************************************************************
3 * Copyright (c) 2002 Sven Wiegand <mail@sven-wiegand.de>
5 * You can use this and modify this in any way you want,
6 * BUT LEAVE THIS HEADER INTACT.
8 * Redistribution is appreciated.
18 *********************************************************************/
21 #include "PropPageFrame.h"
26 static char THIS_FILE
[] = __FILE__
;
31 namespace TreePropSheet
35 //-------------------------------------------------------------------
36 // class CPropPageFrame
37 //-------------------------------------------------------------------
39 CPropPageFrame::CPropPageFrame()
40 : m_bShowCaption(FALSE
),
43 m_dwMsgFormat(DT_CENTER
|DT_VCENTER
|DT_NOPREFIX
|DT_SINGLELINE
)
48 CPropPageFrame::~CPropPageFrame()
53 /////////////////////////////////////////////////////////////////////
57 void CPropPageFrame::ShowCaption(BOOL bEnable
)
59 m_bShowCaption
= bEnable
;
60 SafeUpdateWindow(CalcCaptionArea());
64 BOOL
CPropPageFrame::GetShowCaption() const
66 return m_bShowCaption
;
70 void CPropPageFrame::SetCaption(LPCTSTR lpszCaption
, HICON hIcon
/*= NULL*/)
72 m_strCaption
= lpszCaption
;
73 m_hCaptionIcon
= hIcon
;
74 SafeUpdateWindow(CalcCaptionArea());
78 CString
CPropPageFrame::GetCaption(HICON
*pIcon
/* = NULL */) const
81 *pIcon
= m_hCaptionIcon
;
86 void CPropPageFrame::SetCaptionHeight(int nCaptionHeight
)
88 m_nCaptionHeight
= nCaptionHeight
;
89 SafeUpdateWindow(CalcCaptionArea());
93 int CPropPageFrame::GetCaptionHeight() const
95 return m_nCaptionHeight
;
99 void CPropPageFrame::SetMsgText(LPCTSTR lpszMsg
)
102 SafeUpdateWindow(CalcMsgArea());
106 CString
CPropPageFrame::GetMsgText() const
112 void CPropPageFrame::SetMsgFormat(DWORD dwFormat
)
114 m_dwMsgFormat
= dwFormat
;
115 SafeUpdateWindow(CalcMsgArea());
119 DWORD
CPropPageFrame::GetMsgFormat() const
121 return m_dwMsgFormat
;
125 /////////////////////////////////////////////////////////////////////
126 // Overridable implementation helpers
128 void CPropPageFrame::Draw(CDC
*pDc
)
130 if (GetShowCaption())
131 DrawCaption(pDc
, CalcCaptionArea(), m_strCaption
, m_hCaptionIcon
);
132 DrawMsg(pDc
, CalcMsgArea(), m_strMsg
, m_dwMsgFormat
);
136 CRect
CPropPageFrame::CalcMsgArea()
138 ASSERT(IsWindow(GetWnd()->GetSafeHwnd()));
141 GetWnd()->GetClientRect(rectMsg
);
142 if (GetShowCaption())
143 rectMsg
.top
+= GetCaptionHeight();
149 void CPropPageFrame::DrawMsg(CDC
*pDc
, CRect rect
, LPCTSTR
/*lpszMsg*/, DWORD
/*dwFormat*/)
151 CFont
*pPrevFont
= dynamic_cast<CFont
*>(pDc
->SelectStockObject(DEFAULT_GUI_FONT
));
152 int nPrevBkMode
= pDc
->SetBkMode(TRANSPARENT
);
154 pDc
->DrawText(GetMsgText(), rect
, GetMsgFormat());
156 pDc
->SetBkMode(nPrevBkMode
);
157 pDc
->SelectObject(pPrevFont
);
161 CRect
CPropPageFrame::CalcCaptionArea()
163 ASSERT(IsWindow(GetWnd()->GetSafeHwnd()));
166 GetWnd()->GetClientRect(rectCaption
);
167 if (!GetShowCaption())
168 rectCaption
.bottom
= rectCaption
.top
;
170 rectCaption
.bottom
= rectCaption
.top
+GetCaptionHeight();
176 void CPropPageFrame::DrawCaption(CDC
* /*pDc*/, CRect
/*rect*/, LPCTSTR
/*lpszCaption*/, HICON
/*hIcon*/)
178 // should be implemented by specialized classes
182 /////////////////////////////////////////////////////////////////////
183 // Implementation helpers
185 void CPropPageFrame::SafeUpdateWindow(LPCRECT lpRect
/* = NULL */)
187 if (!IsWindow(GetWnd()->GetSafeHwnd()))
190 GetWnd()->InvalidateRect(lpRect
, TRUE
);
195 } //namespace TreePropSheet