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 » CExtPopupMenuWnd left-hand gradient Collapse All
Subject Author Date
Roger Taplin Oct 15, 2006 - 1:02 AM

I have an owner-draw CExtPopupMenuWnd popup menu displaying various border weights. The menu is elicited from a button within a dialogue. The menu contains labels and lines for border weights varying from zero (no line) to 3 points.

Item drawing is done in a CExtPopupMenuWnd::g_nMsgPopupDrawItem handler within the dialogue.

How can I suppress the menu left-hand gradient (I don’t want to display icons)?

How can I control the menu width?

Can the border weight status of the current selection (a command ID set by an ON_UPDATE_COMMAND_UI_RANGE handler) be accessed from the g_nMsgPopupDrawItem handler’s ExtPopupMenuWnd::DRAWITEMDATA struct?

Thanks,

Roger Taplin

Technical Support Oct 17, 2006 - 12:10 PM

We recommend you follow an absolutely different approach for constructing your "border weight" menu items. You can insert them into a popup menu as tool button like menu items. You can see these menu items in the popup menu displayed from the toolbar’s chevron button. This menu is filled with toolbar buttons which cannot fit in the toolbar. The tool menu items can be displayed in multiple rows with several menu items per row. The last tool menu item in each row is marked with the wrap flag. You can insert several "border weight" tool menu items that have the wrap flag and generate wide icons for them displaying the "border weight" information like you need or like the line width in many painting programs. Using this approach you will not have to implement any custom painting.

You can insert a menu item using the CExtPopupMenuWnd::ItemInsertCommand() method. Get a reference to the CExtPopupMenuWnd::MENUITEMDATA object by invoking the CExtPopupMenuWnd::ItemGetInfo() method. Configure it so it is descrived as the tool button like menu item:

    CExtPopupMenuWnd::MENUITEMDATA & mi = . . .
    mi.SetNoCmdUI( true );
    mi.Enable( true );
    mi.SetToolButton( true );
    mi.SetToolWrap( true );
    CExtCmdIcon _icon;
     // GENERATE THE icon.m_bmpNormal HERE
    mi.SetPopupIcon( _icon );
The icon.m_bmpNormal property is an object of the CExtBitmap type. For instance, if you want to generate a line width icon of the 150x15 size and a black line of some width inside, you should generate a 150x15 HBITMAP (or CBitmap) object which has some known background color (for instance RGB(255,0,255)) of all its pixels and draw a line over this background. Then you can assign this bitmap handle to the icon.m_bmpNormal property and make all the background pixels transparent:
    HBITMAP hBitmap = . . .
    icon.m_bmpNormal.FromBitmap( hBitmap );
    icon.m_bmpNormal.Make32(); 
    icon.m_bmpNormal.AlphaColor( RGB(255,0,255), RGB(0,0,0), BYTE(0) );
    // do not forget to destroy the hBitmap handle finally
    ::DeleteObject( hBitmap );