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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

WiBCommented:
Sorry, didn't get it.
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.
WiBCommented:
Why Color.Transparent?
You should assign the color you want to be transparent.
For example,
  myImageList.TransparentColor = Color.White;
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

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. :)
WiBCommented:
In this case why do you need to set transparent color?
Default value of TransparentColor property is 'Transparent'.
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! :)
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
AJMartinCommented:
Perhaps you could post some sample code which exhibits the problem?
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
AJMartinCommented:
Send them to:
AJMartin (at) orcon (dot) net (dot) nz
WiBCommented:
Wrll, I created project and I don't have any shadows.
Everything's working perfect
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];
    }
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
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.
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++;
    }
}
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
WiBCommented:
I just like the subject
e-mail your code as well
maltese_f@yahoo.com
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.
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
    }
}
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.