Solved

Icon Transparency Problem

Posted on 2003-11-17
20
433 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 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