?
Solved

Icon Transparency Problem

Posted on 2003-11-17
20
Medium Priority
?
456 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 500 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’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

650 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