, OnCtlColor
CDialog
, .
, , :
, - , HBRUSH
return (HBRUSH) m_brush.GetSafeHandle();
, (m_brush
), ( ), .
, , ,
pDC->SetBkColor(RGB(0,0,255));
, , ; .
pDC->SetTextColor(RGB(255,0,0));
, !
- MFC, - : CButton
BS_GROUPBOX
, nCtlColor
CTLCOLOR_STATIC
CTLCOLOR_BTN
!
UINT nStyle = (UINT)(pWnd->GetStyle() & 0x0F);
if(nStyle == BS_GROUPBOX)
{
return (HBRUSH) m_brush2.GetSafeHandle();
}
, , groupbox!
!
, , http://www.codeproject.com/Articles/29016/XGroupBox-an-MFC-groupbox-control-to-display-text : CStatic
, OnPaint()
DrawItem()
. ON_WM_PAINT()
. , OnEraseBkgnd()
ON_WM_ERASEBKGND()
.
, XGroupBox
DDX_ Control
.
, .
CButtons . CMFCButton
DDX_Control
. :
m_bTransparent
TRUE
( afxbutton.cpp ) , , ( , )
SetFaceColor()
SetTextColor()
.
CMFCButton
, CMFCVisualManager
.
. CSpinButton
CMFCSpinButon
, .
OnCtlColor
nCtlColor
, dynamic_cast
.
ON_WM_CTLCOLOR()
.
1:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/53f47162-078a-418f-8067-ee61a81ceeac/checkbox-transparent-color-not-working-in-vs2008?forum=vcgeneral, Groupbox, :
class CMyGroupBox: public CButton
{
protected:
virtual void PreSubclassWindow()
{
SetWindowTheme(*this, _T(""), _T(""));
#pragma comment(lib, "UxTheme.lib")
}
};
, DDX_Control
, , SetTextColor
. HBRUSH , , , , .
2: CMyGroupBox
CMyButton
, PreSubClassWindow
, . , , .
3: - , pDC->SetBkColor(RGB(0,0,255));
; , :( pDC->SetBkMode(TRANSPARENT);
, : (
4:. , , PreSubClassWindow, , .
SetThemeAppProperties(0);
#pragma comment(lib, "UxTheme.lib")
AfxGetMainWnd()->SendMessage(WM_THEMECHANGED, 0U, 0L);
.