Solved

Icon Transparency Problem

Posted on 2003-11-17
20
417 Views
Last Modified: 2012-05-05
Hi, i 'm designing my own desktop application that'll hide windows'. For this i had to put in an imagelist all icons of executable programs. But under Win XP, i'm getting a black shadow for the transparency. Couldn't get rid of it !!!

any idea ????

10x
0
Comment
Question by:zwizeguyz
  • 10
  • 6
  • 4
20 Comments
 
LVL 3

Expert Comment

by:WiB
ID: 9769545
Sorry, didn't get it.
0
 
LVL 1

Expert Comment

by:AJMartin
ID: 9769763
Try setting ColorDepth and TransparentColor. Something like this:

ImageList myImageList = new ImageList ();
myImageList.ColorDepth = ColorDepth.Depth32Bit;
myImageList.TransparentColor = Color.Transparent;
...
// And then your code for adding the icons.
0
 
LVL 3

Expert Comment

by:WiB
ID: 9769961
Why Color.Transparent?
You should assign the color you want to be transparent.
For example,
  myImageList.TransparentColor = Color.White;
0
 
LVL 1

Expert Comment

by:AJMartin
ID: 9776183
quote:
Why Color.Transparent?
You should assign the color you want to be transparent.
For example,
  myImageList.TransparentColor = Color.White;

My images seemed to have "transparent" colours in them. :)
0
 
LVL 3

Expert Comment

by:WiB
ID: 9777211
In this case why do you need to set transparent color?
Default value of TransparentColor property is 'Transparent'.
0
 
LVL 1

Expert Comment

by:AJMartin
ID: 9777221
> In this case why do you need to set transparent color?

Because at the time, I knew no better. Thanks for letting me know! :)
0
 

Author Comment

by:zwizeguyz
ID: 9777239
I already tried all the above solutions, and none of it worked. It seems that windows XP has a special way to deal with icons that has transparency, cuz under win2000 the display of an icon in an ListView gives a perfect result, but when trying it under XP, IE icon, and WMP icon gives a black shadow which is not good.

To see what i'm talking about, create an imagelist in which u add IE icon, and put that imagelist in a listview and try to visualise it under XP.

10x again for your help
0
 
LVL 1

Expert Comment

by:AJMartin
ID: 9777266
Perhaps you could post some sample code which exhibits the problem?
0
 

Author Comment

by:zwizeguyz
ID: 9777292
It's not a code problem it's rather a display problem, if u want i can send you screenshots to see the problem. the code is a little bit complicated to post over here. just gimme your email.

10x
0
 
LVL 1

Expert Comment

by:AJMartin
ID: 9777318
Send them to:
AJMartin (at) orcon (dot) net (dot) nz
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 3

Expert Comment

by:WiB
ID: 9777646
Wrll, I created project and I don't have any shadows.
Everything's working perfect
0
 
LVL 3

Expert Comment

by:WiB
ID: 9777783
public class Form1 : System.Windows.Forms.Form
{
    private System.Windows.Forms.ImageList imageList1;
    protected Graphics myGraphics;

    public Form1()
    {
        ...
        myGraphics = Graphics.FromHwnd(pictureBox1.Handle);
    }
    ...
   
    private void button1_Click(object sender, System.EventArgs e)
    {
        ...
        imageList1.Draw(myGraphics,10,10,index);
        pictureBox1.Image = imageList1.Images[index];
    }
0
 

Author Comment

by:zwizeguyz
ID: 9777849
Well it seems to be a solution, i didn't try it yet but a question came up to my mind, the way u did it means that i have to a put a pictureBox to each icon i have, while the number may vary a lot. Did you try to do it with a Listview and see the prob ? ??

10x again
0
 
LVL 3

Expert Comment

by:WiB
ID: 9778042
You don't have to put a Picture box for each icon.
You just display one image at the time in ImageList:

imageList1.Draw(myGraphics,10,10,index);
pictureBox1.Image = imageList1.Images[index];

where 'index' is an index of image in ImageList

Probably while switching between images you'll have to call Refresh method of PictureBox, that is all.
0
 
LVL 3

Expert Comment

by:WiB
ID: 9778103
private int index = 0;

private void button1_Click(object sender, System.EventArgs e)
{
    if(imageList1.Images.Empty != true)
    {
        if(imageList1.Images.Count == index)
        index=0;
        //pictureBox1.Refresh();
        imageList1.Draw(myGraphics,10,10,index);
        pictureBox1.Image = imageList1.Images[index];
        index++;
    }
}
0
 

Author Comment

by:zwizeguyz
ID: 9778159
Well i appreciate your reactivity but that aint the solution for my prob, what my applciation does is emulating Windows Desktop, so i have to display lot icons and under each a title, just like a real desktop, that's why i display teh ImageList in a ListView.

If you want i can mail u snapshots so u can see what i'm talking about

10x again
0
 
LVL 3

Expert Comment

by:WiB
ID: 9778370
I just like the subject
e-mail your code as well
maltese_f@yahoo.com
0
 
LVL 3

Expert Comment

by:WiB
ID: 9778441
What about this:

private void button1_Click(object sender, System.EventArgs e)
{
    if(imageList1.Images.Empty != true)
    {
        imageList1.Draw(myGraphics,10,10,0);                                            // image with index 0
        imageList1.Draw(myGraphics,10,10+imageList1.ImageSize.Height,1); // image with index 1
    }
}

You need PictureBox only to create graphics.
After you can draw all images from your image list.
0
 
LVL 3

Expert Comment

by:WiB
ID: 9778517
public Form1()
{
    InitializeComponent();
    pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;
    myGraphics = Graphics.FromHwnd(pictureBox1.Handle);
}

private void button1_Click(object sender, System.EventArgs e)
{
    if(imageList1.Images.Empty != true)
    {
        for (int i = 0; i < imageList1.Images.Count; i++)
            imageList1.Draw(myGraphics,10,10+imageList1.ImageSize.Height*i,i);1
    }
}
0
 
LVL 1

Accepted Solution

by:
AJMartin earned 125 total points
ID: 9809576
In direct correspondence, we discovered that placing the .net themes manifest with the .exe solved the problem for the author, along with 32bit colour support for the image list.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now