Icons or Bitmaps? Icon size problem |
Post Reply |
Author | |
robs
Groupie Joined: 09 November 2003 Status: Offline Points: 84 |
Post Options
Thanks(0)
Posted: 29 February 2004 at 12:11pm |
What are people using for their commandBar images? I'm using icons, using .AddIconHandle. Is it safe to say that the commandBars don't utilize the different icon sizes in an icon file? If I load in an icon that has 48x48-256, 32x32-256, 24x24-256, and 16x16-256 sizes, only the 48x48-256 is ever used. So if I use CommandBars.Options.SetIconSize False, 32, 32 The buttonsize changes but the 32x32 icon isn't used. Can anyone shed some light?
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
First of all, I prefer to use BitMaps that stored in an
ImageList. Second, are you trying to have several different icon
sizes in the same commandbar? When I am creating a toolbar that
requires, say, 24x24 icons, I create some Bitmaps that are 24x24 and
place them in a ImageList. After I create the toolbar, I use the
ToolBar.SetIconSize 24, 24 to specify the icons are 24x24.
Below is an example, I have an ImageList that has some BitMaps that are
24x24 (they can be a different size but may look ugly if you use icons
and they are 16x16 but displayed as 24x24, thats why I like BitMaps,
they look better stretched). I can change the numbers in the
SetIconSize to 16x16, 48x48, etc and they all work fine. Doing it
this way you could have two toolbars with different IconSizes.
Dim ToolBar As ICommandBar Set ToolBar = CommandBars.Add("Standard", xtpBarTop) With ToolBar.Controls Set Control = .Add(xtpControlButton, ID_FILE_NEW, "&New", -1, False) Control.DescriptionText = "Create a new document" End With ToolBar.SetIconSize 24, 24 Let me know if I need to explain this better. |
|
robs
Groupie Joined: 09 November 2003 Status: Offline Points: 84 |
Post Options
Thanks(0)
|
I'm not trying to have different icon sizes at the same time, but rather give the user an option. Some users of our applications use mouse (16x16 size), some use a stylus (16x16 or 32x32), and some use their finger(32x32 or 48x48). So as you can see, it would be benifitial for me to load icons that have these 3 sizes and have the commandBars utilize them by using something like ToolBar.SetIconSize Thanks SuperMario
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Ok, I think this will do what your are looking for. I have two
command buttons and two ImageList controls. One imagelist control
has 24x24 Bitmaps, the other has 32x32. When I click on each
command buton the toolbar images change. You could use one
ImageList, but stretching 16x16 bitmaps to 48x48 looks really
ugly. So just add a separate ImageList for each size of Icons and
place the code below in the appropriate menu control.
Private Sub cmdChangeIconSize24_Click() CommandBars(2).SetIconSize 24, 24 CommandBars.AddImageList imlToolbarIcons24 CommandBars.RecalcLayout End Sub Private Sub cmdChangeIconSize32_Click() CommandBars(2).SetIconSize 32, 32 CommandBars.AddImageList imlToolbarIcons32 CommandBars.RecalcLayout End Sub Edited by SuperMario |
|
robs
Groupie Joined: 09 November 2003 Status: Offline Points: 84 |
Post Options
Thanks(0)
|
Thanks for your input and effort. I think I'm going to go the bitmap route. I just need to figure out how to use bitmaps with .AddIconHandle. I'm trying to use high-color bitmaps in a similar fashion to the static bars sample, except each bitmap must be contained in a resource file of a dll. I pulled it off using icons, the only problem is that VB can't handle high-color icons. And when you use LoadResPicture it loads the icons in at 32x32 or what ever the system metric size is set to (small icons or large). If I load in a high-res bitmap (32x32), get the icon handle, and throw it at .AddIconHandle, I can live with the stretching/shrinking to 16x16 and 48x48. I know this sounds like a mess; I'll toy around with it and post some code if I can get it to work. Thanks again for your efforts.
|
|
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
|
robs, Take a look at the vbAccelerator site: http://www.vbaccelerator.com/home/VB/Code/Controls/ImageList /vbAccelerator_Image_List_Control/article.asp They have an alternative to the VB Image List that supports up to 32-bit alpha icons. I use this Image List a lot, and it works with the .AddIconHandle method. They have other nice VB Controls as well with full source code. |
|
robs
Groupie Joined: 09 November 2003 Status: Offline Points: 84 |
Post Options
Thanks(0)
|
Thanks Boyd. I'll have to check it out. So are you using Icons with it, or bitmaps?
|
|
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
|
I'm using Icons. For some of the CommandBars, I'm using the Designer Studio so that users can customize them. But for other CommandBars and certain popup menus, I'm creating them in code and using the .AddIconHandle method. If you take a look at the control on the vbAccelerator site, the .ItemCopyOfIcon property is the one that creates and returns an icon handle for use with the CommandBars.
|
|
robs
Groupie Joined: 09 November 2003 Status: Offline Points: 84 |
Post Options
Thanks(0)
|
Thanks Boyd, that did the trick. That's some sweet code. It looks alot like the code from the staticbars sample except with comments. When I get time, I'd like to redo the staticbars sample using a resource file to load low-res/high res, smalll/large, icons/bitmaps and post it. I'm suprised there haven't been more questions about using high-res icons with the commandbars. Thanks again. |
|
Boyd
Senior Member Joined: 08 December 2003 Location: United States Status: Offline Points: 285 |
Post Options
Thanks(0)
|
I did want to warn you about a bug in the Image List. Certain Unicode operating systems will not work with the image list when you use strings to identify the icon (i.e. by specifying the Key of the icon instead of the Index). I have avoided this by declaring constants for the Index of each of my icons instead of using the string Keys. The following URL explains the bug in detail: http://www.vbaccelerator.com/home/VB/Code/Controls/ImageList /vbAccelerator_Image_List_Control/bugTrak2-1.asp I just wanted to warn you in case you deploy your application to some Unicode systems. I'm glad I could help. |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
In the next release a new control is added called an IconManager which
is a member of the XtremeCommandBars. The IconManager is used to
replace the normal Microsoft ImageList. The support 32-bit Alpha
Icons as well When an Image is
added it automatically generates a disabled and hot images. The
images are added by the index value associated with a CommandBars
control in the toolbar. For example, Const ID_FILE_NEW = 100 is
declared in the General code section, then in the IconManager control
you add 100 and the appropriate images. Another nice feature is
you can add multiple size images for each icon, for example, you can
add both 16x16 and 32x32 icons and simply set the LargeIcons property
to true to use the larger set of icons. Ther are probably a few
other features I can't think of right now, but this is a great new
addition.
Edited by SuperMario |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |