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 » shading in menu with office2007 paint manager Collapse All
Subject Author Date
Pierre MEDART May 25, 2007 - 11:22 AM

How can I get the gradient effect in the leftmost part of the CExtMenuBar when I open a menu ?

Technical Support May 26, 2007 - 11:13 AM

Any part of every component in Prof-UIS is drawn by a paint manager (there are a number of painter managers supported). So please let us know which paint manager you are using?

If it is one of the following paint managers, Office 2003, VS 2005 or Office 2007, you can get the gradient colors of the menu area in this way:

CExtPaintManager * pPM = g_PaintManager.GetPM();
      ASSERT_VALID( pPM );
      ASSERT_KINDOF( CExtPaintManagerOffice2003, pPM );

COLORREF clrNormalMenuItemGradientLeft = pPM->GetColor( INT( CExtPaintManagerOffice2003::_2003CLR_MLA_NORM_LEFT ) );
COLORREF clrNormalMenuItemGradientMiddle = pPM->GetColor( INT( CExtPaintManagerOffice2003::_2003CLR_MLA_NORM_MIDDLE ) );
COLORREF clrNormalMenuItemGradientGright = pPM->GetColor( INT( CExtPaintManagerOffice2003::_2003CLR_MLA_NORM_RIGHT ) );

COLORREF clrRarelyUsedMenuItemGradientLeft = pPM->GetColor( INT( CExtPaintManagerOffice2003::_2003CLR_MLA_RARELY_LEFT ) );
COLORREF clrRarelyUsedMenuItemGradientMiddle = pPM->GetColor( INT( CExtPaintManagerOffice2003::_2003CLR_MLA_RARELY_MIDDLE ) );
COLORREF clrRarelyUsedMenuItemGradientGright = pPM->GetColor( INT( CExtPaintManagerOffice2003::_2003CLR_MLA_RARELY_RIGHT ) );
There are two different gradient types: one is for normal menu items and another one for rarely used menu items in expandable menus. As you can see, the gradient is built using three colors. The code above is correct when the 2003/2005/2007 paint managers are installed and incorrect in the case of Office2000/OfficeXP/NativeXP/Skinnable paint managers.

But typically you don’t need to know them. If you are going to implement some owner drawn menu items, then your code will paint menu item over the drawn by default menu item background. You don’t need to know the gradient colors in this case. You even don’t need to know what’s drawn by default on the background of the menu item at all. If you need to code a custom control which looks like menu (see list box in the main dialog of the ProfUIS_Controls sample application), then you should use the g_PaintManager->PaintMenuItem() code and don’t care about what’s painted on the left area of menu item’s background.

Pierre MEDART May 30, 2007 - 7:27 AM

I want to use either the Office2003 or Office2007 paint manager.

With the Office2003 paint manager, everything works fine since I get the gradient effect in the menu (left part of it, where the icons are drawn)

With the Office2007 paint manager (I tried few ones CExtPaintManagerOffice2007_Silver, CExtPaintManagerOffice2007_Blue, ...) the gradient effect is not rendered in the menu where the icon are drawn.

Technical Support May 30, 2007 - 12:39 PM

To clarify your question, could you send us a screenshot and code snippets which were used for painting menu items?

Pierre MEDART May 31, 2007 - 2:37 AM

I investigated a little bit further. Using

I used the CExtPaintManagerOffice2007_Blue paint manager.

COLORREF clrNormalMenuItemGradientLeft = g_PaintManager.GetPM()->GetColor( INT( CExtPaintManagerOffice2007_Blue::_2003CLR_MLA_NORM_LEFT ) );
    COLORREF clrNormalMenuItemGradientMiddle = g_PaintManager.GetPM()->GetColor( INT( CExtPaintManagerOffice2007_Blue::_2003CLR_MLA_NORM_MIDDLE ) );
    COLORREF clrNormalMenuItemGradientGright = g_PaintManager.GetPM()->GetColor( INT( CExtPaintManagerOffice2007_Blue::_2003CLR_MLA_NORM_RIGHT ) );

I noticed that the clrNormalMenuItemGradientLeft and lrNormalMenuItemGradientMiddle have the same value, so it is difficult to get any gradient effect ?


NB : How can I send you the screenshot ?

Technical Support May 31, 2007 - 6:12 AM

You can see how all color constants are initialized in the CExtPaintManager::InitTranslatedColors() method and it is overridden in any paint manager including the CExtPaintManagerOffice2007_Blue.

So you can derive a class from CExtPaintManagerOffice2007_Blue, override the virtual method InitTranslatedColors(), call the base class implementation and then do some color changes.

You can set a custom paint manager in this way:

g_PaintManager.InstallPaintManager( new CYourPaintManager );