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 » Two sized toolbars, and correlation to menus and bars Collapse All
Subject Author Date
Offer Har Aug 2, 2006 - 10:30 AM

Dead Sir/Madame,

I am trying to implement the following task:
1. Have a toolbars which size can be changed from 16x16 to 24x24 by the user
2. The menu will always show the 16x16 bitmaps
3. The toolbars are 24 bit color depth

I cannot find a simple solution and/or sample for that kind of behavior

I would appreciate a small tutorial or sample that does just that. I saw a lot of requests for that behavior in this forum.

Thanks in advance

Technical Support Aug 2, 2006 - 12:53 PM

Here are the steps you need to follow. Create both 16x16 and 24x24 toolbar resources. The 16x16 toolbar resource should have the same command identifiers as in your menu resource(s) (you can use them during development using class wizard for adding command handler/command updating methods). The 24x24 toolbar resource should have some other button identifiers (different form those in the 16x16 toolbar resource). Now each command has two identifiers: ID_SOME_COMMAND_SMALL used in the 16x16 toolbar and menu and ID_SOME_COMMAND_BIG used in the 24x24 toolbar resource. You should develop the draft version of your toolbars using 16 or 256 color images because Visual Studio toolbar resource editor does not provide the 16/24/32-bit color image editor. Finally, you can replace toolbar bitmaps with those of higher color. As we said, you should use the small version of command identifiers during development. The toolbar window should use the large toolbar resource version, i.e. you should use resource identifier of 24x24 toolbar resource identifier when invoking CExtToolControlBar::LoadToolBar(). The command manager should be updated from both toolbar resources. If you add command handler/command updating methods for the ID_SOME_COMMAND_SMALL command to some class, then this class will have the following message map entries:

ON_COMMAND( ID_SOME_COMMAND_SMALL, OnSomeSmall )
ON_UPDATE_COMMAND_UI( ID_SOME_COMMAND_SMALL, OnUpdateSomeSmall )
You should add the following two lines to the same message map manually:
ON_COMMAND( ID_SOME_COMMAND_BIG, OnSomeSmall )
ON_UPDATE_COMMAND_UI( ID_SOME_COMMAND_BIG, OnUpdateSomeSmall )
As a result, both ID_SOME_COMMAND_SMALL command in menu and ID_SOME_COMMAND_BIG command in toolbar will work like one command. If you encounter any problems with this, you can send us your test project so we can help you.

Offer Har Aug 2, 2006 - 2:58 PM

Hi,

Looks like I’m getting there, but there are still several problems with the proposed approach - How do i change the toolbar from small to large icons at run-time? The user can select if he want’s large or small icons in the toolbar in the customize dialog.

Also, do you have a customize dialog for toolbars in the library? is there any tutorial on how to use it?

Thanks for the prompt response.

Technical Support Aug 3, 2006 - 11:20 AM

The proposed approach deals with a non-customizable UI design only, when you can use CExtToolControlBar::SetButtons() and specify an array of 16x16 or 24x24 command identifiers at run time. This approach is not applicable to customizable applications where toolbars and menus are based on command tree nodes implemented in the CExtCustomizeCmdTreeNode class. The large icons are simply double scaled normal icons and this approach is exactly the same as in all the modern Microsoft applications including Office and latest Visual Studio versions. There is no built-in support for two icons per command and the customization subsystem cannot edit both icons in the customize mode. Although it is possible to implement two icons per command in a toolbar for any customizable application, we would not recommend you hack the standard design. You can code your own toolbar buttons in a CExtBarButton-derived class and override the CExtBarButton::GetIconPtr() virtual method which will return icons of a custom size.