Adding Alphaicons to Toolbar at Runtime |
Post Reply |
Author | |
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
Posted: 31 March 2005 at 8:48am |
Hello! I've got one question to Alphaicons in the CommandBar (and the menus created with the CommandBar-ActiveX). How can I add Buttons with Aplhaicons at runtime. I want to do that like it is showed in the "ShortCutBarReport-Sample", but the only difference is that I want to use Alphaicons (when possible from one file) and not like in the sample, bitmaps (from one file). I hope you can understand me! Yours, Finn! PS.: Sorry for my bad English! |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Something like:
Dim CommandBarIconArray(0 To 7) As Long CommandBarIconArray(0) = ID_FILE_NEW CommandBarIconArray(1) = ID_FILE_OPEN CommandBarIconArray(2) = ID_FILE_SAVE CommandBarIconArray(3) = ID_EDIT_CUT CommandBarIconArray(4) = ID_EDIT_COPY CommandBarIconArray(5) = ID_EDIT_PASTE CommandBarIconArray(6) = ID_FILE_PRINT CommandBarIconArray(7) = ID_HELP_ABOUT If ImageManager.IsAlphaIconsSupported Then ImageManager.I cons.LoadBitmap App.Path & "\Icons\ToolBarAlpha.bmp", CommandBarIconArray, xtpImageNormal Else ImageManager.I cons.LoadBitmap App.Path & "\Icons\ToolBar.bmp", CommandBarIconArray, xtpImageNormal End If Notice I have 2 bitmap files, one that has Alpha Icons, the other does not. Also note that the bitmap file contains exactly 8 16x16 icons. So I must have 8 elements in the CommandBarIconArray, each aqssigned the id of a control. |
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
Thank you! But how can I use Alphaicons with a bitmap file?
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
If Alpha Icons are supported, then the image manager does all the work
for you. You simply provide the bitmap with Alpha Icons.
|
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
OK! But how can I get the Alpha Icons into the bitmap? PS.: Sorry, that I ask so many questions, but I didn't understand how to add Alpha Icons at runtime. |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
You must create the AlphaIcons yourself. The bitmap will be a 32
bit bitmap with the Alpha Channel. There are several programs
that can be used to create them.
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
For example, you can use Axialis IconWorkshop to create the icons and export them as a bitmap.
|
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
I already have the Alpha Icons I want to use in the *.ico format. Know I have to know how to convert them to the bitmap format.
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Then use a program like the one I suggested to export the file as a bitmap.
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Do you have allot of icons? Maybe you can send them to me and I
can export them as a bitmap for you. As an alternative, if you
load all of your icons into the image manager at design time, you can
export them as a bitmap (not sure if it will presrve alpha channel).
|
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
That would be very very very ... very very nice of you! In the attached zip file there are all icons I want to use (there a lot, exactly 338 !!!). The size of the zip file is 20 MB! You find the icons by clicking at the following link: http://www.quickklick.net/downloads/Icons.zip Please send me an e-Mail when you finished converting the icons! My e-Mail-Adress is "finnteegen @ foni.net". The spaces are only for protection against spam-e-Mails. Yours, Finn! |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
That is allot of icons. I'm sorry, but I really don't have time
to convert that many icons. Each of your icons have 8 different
sizes, that amounts to over 2700 bitmaps to extract and make bitmap
lists. When I asked the question I was thinking something like 50
icons or so. I can extract really quick, but it would take a long
time to manually make the lists.
|
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
Sorry! I didn't say it, but you only have to extract the icons in the format 16x16. I hope then it will be possible to extract them! Yours, Finn! |
|
gshawn
Senior Member Joined: 04 October 2004 Status: Offline Points: 227 |
Post Options
Thanks(0)
|
lol Supermario, you dug your own grave :) Finn, that's still 338 icons to compile into a bitmap... That would be very time consuming. Why not create a list of only the icons you will be using in your application? Surely you don't need 4 different printer icons, 4 different recycle bin icons, 4 different bookmark icons, etc.. |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
http://ark42.com/freeimage/alphahlp.exe is a free program (command line utility) that can convert/split/join alpha stuff. alphahlp -fico -cbmp file.ico file.bmp will convert a ico to a bmp You can also tile them into a larger .bmp then like alphahlp -fbmp -i -w16 -h16 -c0 imagestrip.bmp singleimage.bmp |
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
Thank you, but can I also convert all icons into the bitmap format in one progress (sorry, but I don't how to say that )? Yours, Finn! |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
If you are using 2000 or XP, which any programmer probably is, just use "for"...
Edited by Ark42 |
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
Sorry, but what do you mean with that (use "for"...)?
|
|
gshawn
Senior Member Joined: 04 October 2004 Status: Offline Points: 227 |
Post Options
Thanks(0)
|
Try something like this: for %f in (*.ico) do alphahlp -fico -cbmp %f %f.bmp |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Ok, with the help of Ark42 and gshawn this was too easy. I first
extracted all the bmp versions of the icon, then I used Ark42's utility
to merge them into one big list.
2005-04-01_121722_imagelist.zip I used this: for %f in (*.bmp) do alphahlp -fbmp -i -w16 -h16 -c0 imagelist.bmp "%f" This code assumes all the bmp files are int he same directory and that you created a dummy bmp file called imagelist.bmp to hold all the images. The first icon in the list might be the dummy image i used to start the list. (I already had the images extrated as bmp files from earlier using Axialis IconWorkshop, but it appears Ark42's utillity would do this as well) |
|
gshawn
Senior Member Joined: 04 October 2004 Status: Offline Points: 227 |
Post Options
Thanks(0)
|
To expand a little bit more… “For” is a standard Windows 2000/XP command. See http://www.microsoft.com/resources/documentation/windows/xp/ all/proddocs/en-us/ntcmds.mspx#EQAA ). You should follow these steps... more or less: 1) Place alphahlp.exe in your System32 folder or somewhere in your %PATH% 2) Shell to the command prompt by running “CMD.exe” 3) Navigate to the folder where your icons are located 4) Run “for %f in (*.ico) do alphahlp -fico -cbmp %f %f.bmp” to create a 32-bit bitmap for each of the icons in the folder 5) Rename one of these bitmaps to “finalstrip.bmp” This will be the first image your strip. 6) Run “for %f in (*.ico.bmp) do alphahlp -fbmp -i -w16 -h16 -c0 finalstrip.bmp %f” to append the rest of the bitmaps to finalstrip.bmp
I hope this helps, and kudos to Ark42 for a great suggestion.
|
|
gshawn
Senior Member Joined: 04 October 2004 Status: Offline Points: 227 |
Post Options
Thanks(0)
|
Ah well there you go, 10 minutes too late :) I'm still glad I researched it though, I learned quite a bit |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
I know that having the list have to exist for seems annoying, but I usually do something like:
@echo off for %%f in (*.bmp) do ( if exist imagelist.bmp ( alphahlp -fbmp -i -w16 -h16 -c0 imagelist.bmp "%%f" ) else ( copy %%f imagelist.bmp ) ) and put it in a file like MakeIcons.cmd (my actual script is pages long and full of other icon generating stuff) |
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
Hello! @Ark42: That tipp does not work! I don't know why! @gshawn: That tipp works much better, but there still is a problem: At some files (which is an icon file) alphahlp gave the error message, that the icon isn't an ICO file. And most of the icons aplhahlp extracted are not in the format 16x16 (only a few). @SuperMario: Yours version is the best. Your imagelist ist very good and works with my program. Thank you very much!!! And to the others (Ark42 and gshawn): Also "Thank you" to you! Yours, Finn! |
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
Hello! Here I am again! Now I have three 32-it Icons more. How can I add them to your images list. If I use Axialis IconWorkshop and add the converted icons to the imagelist, my application doesn't show the icons in the xp style anymore. And I don't know how to convert them with "alphahlp". I hope anyone of you can help me! Yours, Finn! |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Steps to extract alpha bmp images in Axlias:
1. File->Open->(Open ICO of image you wish to add) 2. Click on the 16x16 version of the ICO file that was opened. 3. File->Export->Image 4. Select "Preserve Alpha Transparency" from the dialog that pops up and select "OK" 5. Give the new bmp a name and save it. Then with Ark's utility.... alphahlp -fbmp -i -w16 -h16 -c0 imagelist.bmp NewImage1.bmp alphahlp -fbmp -i -w16 -h16 -c0 imagelist.bmp NewImage2.bmp alphahlp -fbmp -i -w16 -h16 -c0 imagelist.bmp NewImage3.bmp |
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
Thank you! It works very well! Yours, Finn! |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
alphahlp can split icons as such: alphahlp -fico -m file.ico file- .ico This will generate a new icon for each sub-icon. For example, it might generate: file-0-16x16-8.ico file-1-16x16-32.ico file-2-32x32-8.ico file-3-32x32-32.ico file-4-48x48-8.ico file-5-48x48-32.ico If you had 6 different icon pages in the multipage icon file (256 color, and 32bit with alpha channel, 3 different sizes each) You can convert to .bmp like: alphahlp -fico -cbmp file-1-16x16-32.ico file.bmp |
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
Thank you! I looked at the alphahlp help and saw how to convert icons from one format into the other! But alphahlp is much easier than IconWorkshop from Axialis, because you can run it from the command line! Yours, Finn! |
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
And it's free!
|
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
Yes!!! I think for each program which is shareware, you found a program with the same functionallity which is free! Thank you to both of you (SuperMario and Ark42) for your help! Yours, Finn! |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
I wouldn't say 'found' .. I wrote alphahlp, which is based on the FreeImage library, which I also contribute to quite alot.
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Yes, very nice work Ark42
|
|
finn
Groupie Joined: 11 February 2005 Location: Germany Status: Offline Points: 60 |
Post Options
Thanks(0)
|
Sorry, that I wrote "found"...
|
|
gshawn
Senior Member Joined: 04 October 2004 Status: Offline Points: 227 |
Post Options
Thanks(0)
|
Wow, that's awesome :) Thanks for sharing!
|
|
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 |