Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Icons or Bitmaps? Icon size problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Icons or Bitmaps? Icon size problem

 Post Reply Post Reply
Author
Message
robs View Drop Down
Groupie
Groupie


Joined: 09 November 2003
Status: Offline
Points: 84
Post Options Post Options   Thanks (0) Thanks(0)   Quote robs Quote  Post ReplyReply Direct Link To This Post Topic: Icons or Bitmaps? Icon size problem
    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?

 

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 29 February 2004 at 12:41pm
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. 
Back to Top
robs View Drop Down
Groupie
Groupie


Joined: 09 November 2003
Status: Offline
Points: 84
Post Options Post Options   Thanks (0) Thanks(0)   Quote robs Quote  Post ReplyReply Direct Link To This Post Posted: 29 February 2004 at 1:11pm

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

 

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 29 February 2004 at 1:52pm
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
Back to Top
robs View Drop Down
Groupie
Groupie


Joined: 09 November 2003
Status: Offline
Points: 84
Post Options Post Options   Thanks (0) Thanks(0)   Quote robs Quote  Post ReplyReply Direct Link To This Post Posted: 29 February 2004 at 2:38pm

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.

 

Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 01 March 2004 at 8:27am

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.

Back to Top
robs View Drop Down
Groupie
Groupie


Joined: 09 November 2003
Status: Offline
Points: 84
Post Options Post Options   Thanks (0) Thanks(0)   Quote robs Quote  Post ReplyReply Direct Link To This Post Posted: 01 March 2004 at 9:30am

Thanks Boyd. I'll have to check it out. So are you using Icons with it, or bitmaps?

 

Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 01 March 2004 at 11:30am
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.
Back to Top
robs View Drop Down
Groupie
Groupie


Joined: 09 November 2003
Status: Offline
Points: 84
Post Options Post Options   Thanks (0) Thanks(0)   Quote robs Quote  Post ReplyReply Direct Link To This Post Posted: 01 March 2004 at 9:17pm

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.

Back to Top
Boyd View Drop Down
Senior Member
Senior Member


Joined: 08 December 2003
Location: United States
Status: Offline
Points: 285
Post Options Post Options   Thanks (0) Thanks(0)   Quote Boyd Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2004 at 7:52am

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.

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 13 March 2004 at 11:25pm
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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.