Icon Transparency Problem

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
zwizeguyzAsked:
Who is Participating?
 
AJMartinCommented:
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
 
WiBCommented:
Sorry, didn't get it.
0
 
AJMartinCommented:
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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
WiBCommented:
Why Color.Transparent?
You should assign the color you want to be transparent.
For example,
  myImageList.TransparentColor = Color.White;
0
 
AJMartinCommented:
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
 
WiBCommented:
In this case why do you need to set transparent color?
Default value of TransparentColor property is 'Transparent'.
0
 
AJMartinCommented:
> 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
 
zwizeguyzAuthor Commented:
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
 
AJMartinCommented:
Perhaps you could post some sample code which exhibits the problem?
0
 
zwizeguyzAuthor Commented:
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
 
AJMartinCommented:
Send them to:
AJMartin (at) orcon (dot) net (dot) nz
0
 
WiBCommented:
Wrll, I created project and I don't have any shadows.
Everything's working perfect
0
 
WiBCommented:
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
 
zwizeguyzAuthor Commented:
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
 
WiBCommented:
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
 
WiBCommented:
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
 
zwizeguyzAuthor Commented:
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
 
WiBCommented:
I just like the subject
e-mail your code as well
maltese_f@yahoo.com
0
 
WiBCommented:
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
 
WiBCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.