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 » Menu Images Collapse All
Subject Author Date
Thomas Craddock Nov 20, 2003 - 4:36 AM

Is it possible to prevent images from displaying in the menus when using the the CExtMenuControlBar.

eg.

a CExtCmdItem has its icon set for the toolbar. A menu is loaded with the same ID but you do not want the icon to show in the menu.

Is this senario possible.

Sergiy Lavrynenko Nov 20, 2003 - 7:55 AM

Dear Thomas,

Thank you for the good question.

Your task is possible via handling Prof-UIS menu item painting message. You should add the message handler for the CExtPopupMenuWnd::g_nMsgPopupDrawItem registered message to your frame window:

1) Method declaration
afx_msg LRESULT OnDrawPopupMenuItem( WPARAM wParam, LPARAM lParam );

2) Message map entry
ON_REGISTERED_MESSAGE( CExtPopupMenuWnd::g_nMsgPopupDrawItem, OnDrawPopupMenuItem )

3) Method body

LRESULT CMainFrame::OnDrawPopupMenuItem(
	WPARAM wParam,
	LPARAM lParam
	)
{
CExtPopupMenuWnd::DRAWITEMDATA * pDrawItemData =
		reinterpret_cast
			< CExtPopupMenuWnd::DRAWITEMDATA * >
		 		 ( lParam );
	ASSERT( pDrawItemData != NULL );
	pDrawItemData->PaintDefault(
		true, // force no paint icon
		false, // force no paint text
		false, // force no paint check/radio mark
		false, // force paint as enabled
		false, // force paint as unselected
		);
	// return non-zero value if item repainted
	// by this message handler
	return (!0);
}


This method will "disable" icon painting for any menu in the frame window. To detect whether menu bar has dropped popup menu, you need to invoke CExtToolControlBar::GetMenuTrackingButton() method of the menu bar window. This method return a value which is less than zero if no popup menu is dropped from the menubar.

Best regards, Sergiy.

Thomas Craddock Nov 20, 2003 - 7:59 PM

Thankyou for your quick reply Sergiy

I seem to have some issue with getting this method to work.

Here is how I have followed it through (sorry if its a hard to follow my explanations could do with some work)

The CExtPopupMenuWnd::g_nMsgPopupDrawItem messgae is sent from the CExtPopupMenuWnd::DRAWITEMDATA::DoOwnerDrawPainting() function.

The above function is called from CExtPopupMenuWnd::_DoPaint function only when the TPMX_OWNERDRAW_FIXED flag is not set on the m_dwTrakFlags variable according to line 6638 of ExtPopupMenuWnd.cpp

m_dwTrackFlags is set on line 5654 of ExtPopupMenuWnd.cpp from the function CExtPopupMenuWnd::_TrackPopupMenu ’s parameter dwTrackflags

This parameter is passed through from CExtPopupMenuWnd::TrackPopupMenu which is call from CExtBarButton::OnTrackPopup where the dwTracksFlag is hard coded to set the TPMX_OWNERDRAW_FIXED flag on line 1226 of ExtToolControlBar.cpp

The only place I could find where the TPMX_CUSTOMIZE_MODE flag is unset was in the CExtPopupMenuWnd::TrackPopupMenu function on line 4878 of ExtPopupMenuWnd.cpp but this only occurs if the TPMX_CUSTOMIZE_MODE flag is set which I assume is only set when the ui is in customize mode.

So based on that is it true that the CExtPopupMenuWnd::g_nMsgPopupDrawItem message will not be sent when a CExtPopupMenuWnd is displayed from a CExtBarButton which makes up the CExtMenuControlBar

Sergiy Lavrynenko Nov 21, 2003 - 6:12 AM

Dear Tomas,

It seems . . . I have misunderstanding . . . or . . . you are using the old version of the library. The suggested source code in my previous message is working and line 1611 of ExtToolControlBar.cpp is:

DWORD dwTrackFlags =
		OnGetTrackPopupFlags()
		|  TPMX_COMBINE_DEFAULT
		| TPMX_OWNERDRAW_FIXED
		; 
These lines are part of the CExtBarButton::OnTrackPopup() method. The CExtBarButton class implements any kind of the button in toolbar/menubar and there are no strong differences between buttons inside CExtToolControlBar and inside CExtMenuControlBar. All the popup menus (instances if CExtPopupMenuWnd class) dropped from toolbar/menubar always have the TPMX_OWNERDRAW_FIXED style and menu item painting message will always be sent to your CMainFrame window.

You should receive e-mail with my sample project attached. This project includes the same menu painting code I wrote in my previous message.

Best regards, Sergiy.

P.S. my sample source code was tested with Prof-UIS version 2.22 freeware which is available to download from this site.