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 icon size Collapse All
Subject Author Date
Ian McIntosh Aug 12, 2008 - 2:55 AM

Hi,


Is it possible to set the icon size for a CExtPopupMenuWnd?

Ian McIntosh Aug 14, 2008 - 5:20 AM

The last reply does not seem to be relevant.


I am using a stand-alone popup menu, calling TrackPopupMenu().


A simplified code extract is:



CExtPopupMenuWnd* pMenu =


pMenu->CreatePopupMenu(hWnd);


new CExtPopupMenuWnd;

pMenu->ItemInsertCommand(1, -1, "Item without icon");



pMenu->ItemInsertCommand(2, -1, "Item with icon", true, hIcon, bCheck);


// I would like not to have to do the following:



 


{


SIZE size; size.cx = 16; size.cy = 16;


pMenu->ItemGetIcon(pMenu->ItemGetCount()-1).Scale(size);


}


// end of bit I would like not to do



pMenu->TrackPopupMenu(CExtPopupMenuWnd::__AT_NOISE, pos.x, pos.y);


 


I have 2 issues:


1. I would like the items with an icon to be the same height as the items without an icon.


2. I would like icons to show at size 16x16 by default (without having to explicitly set each one) if possible.


if (hIcon)

Technical Support Aug 16, 2008 - 1:15 PM

We suspect you are using the LoadIcon() Win32 API which always loads a 32x32 icon image regardless of the image format stored inside the icon. If our guess is correct, you should simply use the LoadImage() Win32 API for loading 16x16 icons.

Technical Support Aug 13, 2008 - 12:45 PM

If you are constructing popup menus by handling the CExtPopupMenuWnd::g_nMsgPrepareOneMenuLevel registered message, you should inform Prof-UIS about whether any of menu items were modified:

<code><pre>LRESULT CYourClass::OnExtMenuPrepareLevel( WPARAM wParam, LPARAM lParam )
{
      lParam;
      CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
            reinterpret_cast
            < CExtPopupMenuWnd::MsgPrepareMenuData_t * >
            ( wParam );
      ASSERT( pData != NULL );
      CExtPopupMenuWnd * pPopup = pData->m_pPopup;
. . .
      // if the pPopup menu was modified, then you should invoke the following:
      pData->m_bMenuChanged = true;
. . .


Ian McIntosh Aug 13, 2008 - 2:10 AM

I am using ItemInsertCommand, so icons are not taken from command manager.


I use the version of ItemInsertCommand that passes in an HICON.


The default seems to be an icon size larger that 16x16 (looks more like 24x24).


I have found I can use ItemGetIcon to get the icon then call scale to set it to 16x16. This correctly sets the icon to 16x16, but the height of the menu item is still larger than one which does not have an icon set.

Ideally, I would like to set the default icon size so that I can pass in icons as HICONs and not have to resize them.


Technical Support Aug 12, 2008 - 1:44 PM

The Prof-UIS popup menu uses icons stored in the command manager. In most cases the command icons are appeared in the command manager due to updating it from toolbar resources and these icons have the size of 16x16. You can update the command manager from a toolbar resource based on larger images so you can have exactly the same larger icons in menus. The popup menus displayed from the menu bar in the FunnyBars sample application contain command menu items with icons of different sizes. The CExtPopupMenuWnd window displays menu icons "as is" without resizing. If you need different size icons for the same command in toolbar and in menu, then you should use different command identifiers for menu item and toolbar button, update command icons for these two commands in the command manager from different toolbar resources and connect these two commands to the same command updating and/or handler methods in the message map.