Professional User Interface Suite, Copyright FOSS Software Inc. Help Published with Permission.

You can customize the look of any menu item or subitem to make it fit your taste. This can be done using custom drawing. For example, the CPagePopupMenus::OnDrawPopupMenuItem() method in the ProfUIS_Controls sample 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 that this custom menu item features 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 font. 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
)