473,230 Members | 1,407 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,230 software developers and data experts.

Alpha-Blended Icons on Toolbar Buttons

Al
Hi All,

I am trying to get a 24x24 "Windows XP" icon to display correctly on a
button in my toolbar. My icon has 8 layers (16x16, 16x16, 24x24, 24x24,
32x32, 32x32, 48x48, 48x48) with each size having a 256 and windows xp
colored image. When my application runs, the icon with 256 colors appears
rather than the xp icon. I have tried using a manifest as well as
Application.EnableVisualStyles. No luck.

I have seen numerous articles about this problem but only a few solutions,
none of which I could not get to work. I would be very grateful if anybody
could point me to an actual solution.

Thanks,

Al
Nov 20 '05 #1
3 2438
You need to add the Icons to the ImageList at runtime. At designtime the
ImageList Flattens the Alpha.

So as not to have to distribute the Icons seperately you can add them as
Embedded Resources.
Example follows:

Assumes Toolbar(ToolBar1) with 2 buttons on Form1, 2 Icons(icon1.ico,
icon2.ico) set as Embedded Resource and ImageList1.ColorDepth = Depth32Bit
\\\
Public Class Form1
Inherits Form

Shared Sub Main()
Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(New Form1)
End Sub

#Region " Windows Form Designer Generated Code "
'Code not shown
#End Region

Private Sub Form_Load(...)...
Dim AlphaIcon1 as New Icon(GetType(Form1), "icon1.ico")
Dim AlphaIcon2 as New Icon(GetType(Form1), "icon2.ico")
Imagelist1.Images.Add(AlphaIcon1)
Imagelist1.Images.Add(AlphaIcon2)
Toolbar1.Buttons(0).ImageIndex=0
Toolbar1.Buttons(1).ImageIndex=1
End Sub
///

Note that the Iconnames are cAse sEnsitive. i.e. "icon1.ico" <> "icon1.ICO"
"Al" <as****@nospamssimed.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I am trying to get a 24x24 "Windows XP" icon to display correctly on a
button in my toolbar. My icon has 8 layers (16x16, 16x16, 24x24, 24x24,
32x32, 32x32, 48x48, 48x48) with each size having a 256 and windows xp
colored image. When my application runs, the icon with 256 colors appears
rather than the xp icon. I have tried using a manifest as well as
Application.EnableVisualStyles. No luck.

I have seen numerous articles about this problem but only a few solutions,
none of which I could not get to work. I would be very grateful if anybody could point me to an actual solution.

Thanks,

Al

Nov 20 '05 #2
Al
Thanks Mick. That worked perfectly. I am surprised someone has to take the
time to program something like this.

Al
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:uF*************@TK2MSFTNGP12.phx.gbl...
You need to add the Icons to the ImageList at runtime. At designtime the
ImageList Flattens the Alpha.

So as not to have to distribute the Icons seperately you can add them as
Embedded Resources.
Example follows:

Assumes Toolbar(ToolBar1) with 2 buttons on Form1, 2 Icons(icon1.ico,
icon2.ico) set as Embedded Resource and ImageList1.ColorDepth = Depth32Bit
\\\
Public Class Form1
Inherits Form

Shared Sub Main()
Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(New Form1)
End Sub

#Region " Windows Form Designer Generated Code "
'Code not shown
#End Region

Private Sub Form_Load(...)...
Dim AlphaIcon1 as New Icon(GetType(Form1), "icon1.ico")
Dim AlphaIcon2 as New Icon(GetType(Form1), "icon2.ico")
Imagelist1.Images.Add(AlphaIcon1)
Imagelist1.Images.Add(AlphaIcon2)
Toolbar1.Buttons(0).ImageIndex=0
Toolbar1.Buttons(1).ImageIndex=1
End Sub
///

Note that the Iconnames are cAse sEnsitive. i.e. "icon1.ico" <> "icon1.ICO"

"Al" <as****@nospamssimed.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I am trying to get a 24x24 "Windows XP" icon to display correctly on a
button in my toolbar. My icon has 8 layers (16x16, 16x16, 24x24, 24x24,
32x32, 32x32, 48x48, 48x48) with each size having a 256 and windows xp
colored image. When my application runs, the icon with 256 colors appears rather than the xp icon. I have tried using a manifest as well as
Application.EnableVisualStyles. No luck.

I have seen numerous articles about this problem but only a few solutions, none of which I could not get to work. I would be very grateful if

anybody
could point me to an actual solution.

Thanks,

Al


Nov 20 '05 #3
GTH.

As Workarounds go, this is one of the simple ones, although if you don't
know about it, it could turn out to be an impossible task.
"Al" <as****@nospamssimed.com> wrote in message
news:eL**************@tk2msftngp13.phx.gbl...
Thanks Mick. That worked perfectly. I am surprised someone has to take the time to program something like this.

Al
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in message news:uF*************@TK2MSFTNGP12.phx.gbl...
You need to add the Icons to the ImageList at runtime. At designtime the
ImageList Flattens the Alpha.

So as not to have to distribute the Icons seperately you can add them as
Embedded Resources.
Example follows:

Assumes Toolbar(ToolBar1) with 2 buttons on Form1, 2 Icons(icon1.ico,
icon2.ico) set as Embedded Resource and ImageList1.ColorDepth = Depth32Bit
\\\
Public Class Form1
Inherits Form

Shared Sub Main()
Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(New Form1)
End Sub

#Region " Windows Form Designer Generated Code "
'Code not shown
#End Region

Private Sub Form_Load(...)...
Dim AlphaIcon1 as New Icon(GetType(Form1), "icon1.ico")
Dim AlphaIcon2 as New Icon(GetType(Form1), "icon2.ico")
Imagelist1.Images.Add(AlphaIcon1)
Imagelist1.Images.Add(AlphaIcon2)
Toolbar1.Buttons(0).ImageIndex=0
Toolbar1.Buttons(1).ImageIndex=1
End Sub
///

Note that the Iconnames are cAse sEnsitive. i.e. "icon1.ico" <>

"icon1.ICO"


"Al" <as****@nospamssimed.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I am trying to get a 24x24 "Windows XP" icon to display correctly on a
button in my toolbar. My icon has 8 layers (16x16, 16x16, 24x24, 24x24, 32x32, 32x32, 48x48, 48x48) with each size having a 256 and windows xp
colored image. When my application runs, the icon with 256 colors

appears rather than the xp icon. I have tried using a manifest as well as
Application.EnableVisualStyles. No luck.

I have seen numerous articles about this problem but only a few solutions, none of which I could not get to work. I would be very grateful if

anybody
could point me to an actual solution.

Thanks,

Al



Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Marek Kurowski | last post by:
Yo! What mean when program is ALPHA or BETA version? I suppose it is not release version of program, but I don't know what it exactly mean. What it mean in your opinion? Marek Kurowski
3
by: instruo | last post by:
I'm using the System.Drawing.Bitmap class for loading a 32-bit bmp file which includes an alpha channel. The problem is, when it gets loaded (just using the Bitmap(string filename) constructor),...
1
by: RicercatoreSbadato | last post by:
I have notice that my images have the value Image.Flags = 2 (HasAlpha). How Can I set the Flags to 1? I would like to eliminate the alpha channel... -- RicercatoreSbadato
6
by: TJO | last post by:
Below is some sample code that fades div tags that is not working in IE 6.0.29 on xp sp2. Can anyone help see why the if(ie5) document.getElementById(divID).filters.alpha.opacity lines are not...
0
by: Anthony Baxter | last post by:
On behalf of the Python development team and the Python community, I'm happy to announce the first alpha release of Python 2.5. This is an *alpha* release of Python 2.5, and is the *first*...
0
by: Anthony Baxter | last post by:
On behalf of the Python development team and the Python community, I'm happy to announce the second alpha release of Python 2.5. This is an *alpha* release of Python 2.5. As such, it is not...
6
by: tommaso.gastaldi | last post by:
In a previous post I have been asking about a way to test Alpha Transparency. Bob and Michael have kindly provided some ideas. Here I would like to share the function I have prepared, for the...
2
by: Mitoshima | last post by:
The pre-alpha version of Tic Tac Toe Plus, which is actually a Tic Tac Toe game, will be made available on Wed 27th. Your contribution is needed and will be appreciated as we would like persons...
3
by: Gernot Frisch | last post by:
Hi, I have this code that blends 2 pixels, but it's not really fast. Can someone help me speeding it up? #define GETR(a) (unsigned char)(((((a)>>11)&31)*255)/31) #define GETG(a) (unsigned...
1
by: perl9user | last post by:
Hi, Does anyone know how to get the alpha-numeric numbering scheme in perl ? For example the numberic => 0,1,2,...9,10,11,12,...99,100,... # $x = 0;$x++; lower-alpha =>...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.