469,576 Members | 1,824 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,576 developers. It's quick & easy.

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 2275
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Marek Kurowski | last post: by
3 posts views Thread by instruo | last post: by
1 post views Thread by RicercatoreSbadato | last post: by
6 posts views Thread by TJO | last post: by
reply views Thread by Anthony Baxter | last post: by
reply views Thread by Anthony Baxter | last post: by
6 posts views Thread by tommaso.gastaldi | last post: by
2 posts views Thread by Mitoshima | last post: by
3 posts views Thread by Gernot Frisch | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.