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 General Discussion » Customizing menus (text font, color, ...) Collapse All
Subject Author Date
Moby Dick Feb 17, 2005 - 4:06 AM

Hello all,


I need to change for each items of a sub-menu

Moby Dick Feb 17, 2005 - 4:11 AM

Sorry, but the page reloaded....


So I need to change the font style and the font color for each item of a sub-menu.


Can you tell me how to do this ?


Best regards,

Technical Support Feb 17, 2005 - 6:44 AM

Of course, you can customize the look of any menu item and subitem in the way that most closely fits your tastes. For this you need to use custom drawing. For example, the CPagePopupMenus::OnDrawPopupMenuItem() method in the ProfUIS_Controls sample application handles the CExtPopupMenuWnd::g_nMsgPopupDrawItem registered windows message and performs custom drawing of the menu item specified with ID_OWNERDRAW_ITEM. So, if you select the Popup Menu page in this application and invoke the context menu, you will see this custom menu item with a gradient background. The pointer to the CExtPopupMenuWnd::DRAWITEMDATA structure is passed in the WPARAM parameter of the CExtPopupMenuWnd::g_nMsgPopupDrawItem message. So, first of all, your painting code should invoke pDrawItemData->PaintDefault( false, true ) to draw the entire menu item but its text. To compute the text rectangle, use this code:

CRect rcText = *pDrawItemData->m_pRectItem;
rcText.left = pDrawItemData->m_pItemData->GetIconAreaWidth();

After that you can draw a text string using your custom fonts. Please do not forget to add the definition below to the message map of the window class that repaints menu items:
ON_REGISTERED_MESSAGE(
        CExtPopupMenuWnd::g_nMsgPopupDrawItem,
        OnDrawPopupMenuItem
        )