473,503 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2451
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
4499
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
17346
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
4270
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
6335
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
1009
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
1085
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
3643
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
1909
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
3611
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
1418
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
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5572
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.