By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,990 Members | 2,138 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,990 IT Pros & Developers. It's quick & easy.

Alpha-Blended Icons on Toolbar Buttons

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.