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