Professional UI Solutions
Site Map   /  Register
 
 

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.

Forums » Prof-UIS Tech Support » transparent control in gradient background window Collapse All
Subject Author Date
Chris Anderson Sep 4, 2007 - 7:12 PM

I tried to create transparent controls on a background window. With 2007 themes, the background window is gradient but the controls ( CExtLabel, CExtCheckBox, CExtRadioButton ) are not, which doesn’t look good.

I managed to make the label work, but still have problem with the check box and radio button. What I did is :

1. create a CWnd based window, and paint its client rect with
g_PaintManager->PaintDocumentClientAreaBkgnd

( for some reason we decided not to use prof-uis class for the background window )

2. create a new checkbox ( CExtCheckBox )

When I debugged into the code ( Prof-UIS v281 ) with 2007 luna blue theme, it looks that CExtButton::DrawItem() ends up calling CExtPaintManagerOffice2003::PaintDockerBkgnd() to paint the background rect of the check box, even though it’s a 2007 theme. See the code snippet below :

COLORREF clrLeft = GetColor( _2003CLR_GRADIENT_DARK, NULL );
COLORREF clrRight = GetColor( _2003CLR_GRADIENT_LIGHT, NULL );
    if( clrLeft == clrRight )
    {
        dc.FillSolidRect( &rcDst, clrLeft );
        __EXT_PROFUIS_PAINT_EVALUATION_LOGO( dc, &rcDst, bClientMapping, NULL );
        return true;
    }

clrLeft and clrRight are equal, therefore it simply call FillSolidRect() and return. This would make the check box rect non-transparent ?

The call stack looks like :

>    CExtPaintManagerOffice2003::PaintDockerBkgnd( ) Line 22557
    CExtPaintManagerOffice2007_Impl::PaintDockerBkgnd() Line 45712     
    CExtPaintManagerOffice2003::PaintDockerBkgnd() Line 22534
    CExtCheckBox::_RenderImpl()

For me painting the bkgd area is really not necessary, what I need is simply make this transparent. Is there any way to do this ?

Thanks

Technical Support Sep 5, 2007 - 12:13 PM

The themed background is based on algorithms implemented in the paint manager. When you see a check box button with a background that is consistent with that of the parent dialog, this consistent background is provided by some calculations and painting invocations in the paint manager. Please note the dialog is not responsible for painting the background of its children controls. This is the default design and it was implemented due to optimization issues because querying chains of parent windows for painting the background of child controls can be quite slow especially if you have too much windows created at a time. In simple words, Prof-UIS provides a consistent background by default but it is not inherited between child/parent windows.

Now time for good news. There is another option. Prof-UIS supports inherited background painting, but this feature is turned off by default. You can see two configurable types of the inherited background in the TabbedBars sample: the consistent gradient background of tab page dialogs in a One Note tab page container window created instead of the main SDI view and a hurricane-like background in the main frame window. To enable the inherited background, you should invoke the following code both at startup and when you changes the current paint manager:

      pPM->m_bCustomBackgroundInheritanceEnabled = true;
After that each Prof-UIS control sends the CExtPaintManager::g_nMsgPaintInheritedBackground registered message to their parent windows until one of the parent windows in the chain paints a custom background for the control. The CMainFrame::OnMsgPaintInheritedBackground() and CChildView::OnMsgPaintInheritedBackground() methods in the TabbedBars sample demonstrate how to handle the CExtPaintManager::g_nMsgPaintInheritedBackground registered message. So, your message handler should paint control backgrounds using the g_PaintManager->PaintDocumentClientAreaBkgnd(...) code instead of gradients and hurricanes painted in our sample application. The CExtPaintManager::g_nMsgPaintInheritedBackground registered message can be send for painting of both client and non client window areas. You should get a completely consistent inherited background.