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

Because any particular command cannot be assigned icons of different sizes, you should use different command identifiers in toolbars and menus and assign the same command handlers to them. The steps below outline how you can create a small menu item (16x16) and a large toolbar button (32x32) which will be working as a single command (e.g. File | Open):

1) Add a menu item (ID_FILE_OPEN_16X16) to the IDR_MAINFRAME menu resource.

2) Add a new icon (ID_FILE_OPEN_32X32) to the IDR_MAINFRAME toolbar resource with 32x32 icons.

3) Create a toolbar resource (IDR_MAINFRAME_SMALL_ICONS) and add a small version (16x16) of the ID_FILE_OPEN_32X32 icon to this resource. Specify ID_FILE_OPEN_16X16 as is its ID.

4) Initialize the IDR_MAINFRAME toolbar using the CExtToolControlBar::LoadToolbar() method. This method indirectly updates the command manager with information about commands in this toolbar including ID_FILE_OPEN_32X32.

5) Update the command manager with information about commands in the IDR_MAINFRAME_SMALL_ICONS toolbar. You can do this directly using a method call like as follows:

g_CmdManager->UpdateFromToolBar( ..., IDR_MAINFRAME_SMALL_ICONS )

6) Add a command handler and a command update handler for the ID_FILE_OPEN_32X32 command to the main frame class using the Visual Studio's Wizard. The following line(s) will be added to the message map of the CMainFrame class:

ON_COMMAND( ID_FILE_OPEN_32X32, OnFileOpen32X32 )
ON_UPDATE_COMMAND_UI( ID_FILE_OPEN_32X32, OnUpdateFileOpen32X32 )

7) Use OnFileOpen32X32() and OnUpdateFileOpen32X32() added at the previous step as handler methods for the ID_FILE_OPEN_16X16 command by adding these two lines to the message map of the CMainFrame class:

ON_COMMAND( ID_FILE_OPEN_16X16, OnFileOpen32X32 )
ON_UPDATE_COMMAND_UI( ID_FILE_OPEN_16X16, OnUpdateFileOpen32X32 )