|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Richard Gardner
|
Mar 1, 2008 - 10:42 AM
|
HI I have a dialog derived from class CDlgForex : public CExtNCW <CExtResizableDialog> what I want to achieve is to make its background black. I tried to write such code
BOOL CDlgForex::OnEraseBkgnd(CDC* pDC) { CRect rc; GetClientRect(&rc); pDC->FillRect(&rc, &m_brush); return TRUE;
//return CExtNCW<CExtResizableDialog>::OnEraseBkgnd(pDC); } HBRUSH CDlgForex::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CExtNCW<CExtResizableDialog>::OnCtlColor(pDC, pWnd, nCtlColor);
pDC->SetBkColor(RGB(0, 0, 0));
// TODO: Return a different brush if the default is not desired
return (HBRUSH)m_brush; }
where CBrush m_brush; m_brush.CreateSolidBrush(RGB(0, 0, 0));
but with no luck, background is always drawn with the color for currently selected UI theme.
What would be the steps to achieve this goal?
Thx
|
|
Technical Support
|
Mar 3, 2008 - 2:34 PM
|
The Win32/MFC custom dialog background approach is based on HBRUSH queries through WM_CTLCOLOR messages. This is convenient if you need to implement some single color or bitmap pattern based background. But Prof-UIS themes often use themed backgrounds with gradients and rule based skin bitmap paintings stretched into entire client area of dialog window. The entire dialog background should be automatically inherited by dialog child windows deeply and not only one level. The same is related to frame and other windows. Prof-UIS classes does not use WM_CTLCOLOR messages, they use paint manager based inherited background painting algorithm instead. You can see it in action in the TabbedBars sample application where you can configure background painting options in the third tab page of the One Note tab page container created as SDI child view. The algorithm is based on the CExtPaintManager::g_nMsgPaintInheritedBackground message sent by the paint manager to windows. If windows in your project does not handle this message like demonstrated in the TabbedBars sample application, then the default themed background will be painted.
|
|