We follow the approach used in Microsoft Office applications, when there is only one icon per command. This icon is used both in toolbars and menus. You should use two different command identifiers if you want to see 16x16 icons in a menu and 24x24 icons in a toolbar. This restriction does not make development harder. For example, you have an ID_FILE_SAVE
button in a toolbar based on 24x24 images and the main frame window handles this command:
ON_COMMAND( ID_FILE_SAVE, OnFileSave )
Now you can define and use a
ID_FILE_SAVE_SMALL
command in your menu resource. To connect this command to the
CMainFrame::OnFileSave()
handler method, you should manually add only one line to the message map:
ON_COMMAND( ID_FILE_SAVE_SMALL, OnFileSave )
Now you have two different commands which work like one command. The file save command in the toolbar displays a 24x24 icon. The file save command in the menu does not have an icon at all. To display the 16x16 icon in the menu, create a new toolbar resource with 16x16 images and define
ID_FILE_SAVE_SMALL
button in it. This toolbar resource will actually never be used in any toolbar window. We should simply put its icons into the command manager for making them accessible in menus. This should be done by invoking
g_CmdManager->UpdateFromToolBar(...)
during initialization (typically somewhere at the beginning of the
CMainFrame::OnCreate()
method).