Form transparency issues

  • Thread starter othell m. via .NET 247
  • Start date
O

othell m. via .NET 247

Recently I wanted to create a small little program that could siton the desktop and not block the desktop wallpaper. There aretwo methods to accomplish this ( that I am aware of ).

1) create a solid color bmp as a background image and set thetransparency key to match its color
2) specify the form's background color with a matchingtransparency key

Now my issues with both methods, but first it should be knownthat I have set the forms to have no border or title bar andhave implemented code that allows me to click-and-hold anywhere( with exceptions listed below ) on the form and move it. Thedata actually displayed on the form is just text and onerectangle, all drawn by me ( there are no controls on the formitself ).

1) I have two issues with this method, although it is what I'mprefering to use at the moment. The first seems to be thediscrepancy between how the program is handled when thecomputer's Color Depth is 32bit or when it is less than 32bit (16bit ). When the color depth is 32bit then I am able to clickon the entire area the form inhabits ( even that which istransparent ) and move it, but if the color depth is less than32bit ( 16bit ) then only the drawn text or rectangle outline (since it has no fill ) can be clicked to drag the programaround. Clicking on the transparent areas just passes the clickthrough the form to whatever is below ( even when I know theform has focus ). I'd like to be able, regardless of thedesktop's color depth, to click anywhere within the form areaand move the application.

The second issue I have with this method occurs when I take myexecutable and put it on another PC ( my PC is XP Pro, the otherPC is XP Home.. Both SP2 ). The problem is similar, but alittle different. When the 2nd PC's color depth is at 32bit,the transparency does not work. The green/lime ( that's thetransparent color I'm using ) background shows. Needless to saythis is not acceptable. When I change the color depth to lessthan 32bit ( 24bit this time ), the transparency actually works,but I come across the same issue of clicks on the transparentareas just passing through.

2) With this method I have not tried it on a 2nd PC yet ( I don'thave it available where I am atm ). Its basically the same"issue" as mentioned above with color depth less than 32bit,except it does it with a color depth of 32bit and 16bit. Clickson the transparent areas just pass right through. I'm temptedto just go with this method and possibly make one area on theform that is meant to be used to drag it around ( similar to theidea of the box that appears to move tables in MS Word ), butI'm hoping there's a solution I'm unaware of before I do that.

Anyways, all of this brings up some interesting questions.

-What does color depth have to do with transparency handling?
-Does the version of XP ( Home or Pro ) handle transparencydifferently?

Probably some more questions also.

Not sure if it matters, but I'm doing all of this in C#.

So any ideas to get pass any of these issues?

Thanks in advance.
 
J

Jim H

I ran into a similar problem with transparency recently. I am running on 2
monitors. On one monitor the transparent background (blue on mine) was
completely visible, but if I dragged it over to the other monitor it was
transparent just like it should be. If I changed my color depth on the
primary monitor from 32 bit to 16 bit the transparency worked fine. I did
accidentally find an work around though. While writing code to change these
child windows back and forth from frameless with transparent backgrounds to
framed windows with control color backgrounds programmatically the
transparency started working.

Maybe setting your controls/windows up programmatically will work for you
too. Good luck.
Jim

Recently I wanted to create a small little program that could sit on the
desktop and not block the desktop wallpaper. There are two methods to
accomplish this ( that I am aware of ).

1) create a solid color bmp as a background image and set the transparency
key to match its color
2) specify the form's background color with a matching transparency key

Now my issues with both methods, but first it should be known that I have
set the forms to have no border or title bar and have implemented code that
allows me to click-and-hold anywhere ( with exceptions listed below ) on the
form and move it. The data actually displayed on the form is just text and
one rectangle, all drawn by me ( there are no controls on the form itself ).

1) I have two issues with this method, although it is what I'm prefering to
use at the moment. The first seems to be the discrepancy between how the
program is handled when the computer's Color Depth is 32bit or when it is
less than 32bit ( 16bit ). When the color depth is 32bit then I am able to
click on the entire area the form inhabits ( even that which is
transparent ) and move it, but if the color depth is less than 32bit (
16bit ) then only the drawn text or rectangle outline ( since it has no
fill ) can be clicked to drag the program around. Clicking on the
transparent areas just passes the click through the form to whatever is
below ( even when I know the form has focus ). I'd like to be able,
regardless of the desktop's color depth, to click anywhere within the form
area and move the application.

The second issue I have with this method occurs when I take my executable
and put it on another PC ( my PC is XP Pro, the other PC is XP Home.. Both
SP2 ). The problem is similar, but a little different. When the 2nd PC's
color depth is at 32bit, the transparency does not work. The green/lime (
that's the transparent color I'm using ) background shows. Needless to say
this is not acceptable. When I change the color depth to less than 32bit
( 24bit this time ), the transparency actually works, but I come across the
same issue of clicks on the transparent areas just passing through.

2) With this method I have not tried it on a 2nd PC yet ( I don't have it
available where I am atm ). Its basically the same "issue" as mentioned
above with color depth less than 32bit, except it does it with a color depth
of 32bit and 16bit. Clicks on the transparent areas just pass right
through. I'm tempted to just go with this method and possibly make one area
on the form that is meant to be used to drag it around ( similar to the idea
of the box that appears to move tables in MS Word ), but I'm hoping there's
a solution I'm unaware of before I do that.

Anyways, all of this brings up some interesting questions.

-What does color depth have to do with transparency handling?
-Does the version of XP ( Home or Pro ) handle transparency differently?

Probably some more questions also.

Not sure if it matters, but I'm doing all of this in C#.

So any ideas to get pass any of these issues?

Thanks in advance.
 
J

Jim H

I take it back. It stopped working today after I made some non-related code
changes. :(
Recently I wanted to create a small little program that could sit on the
desktop and not block the desktop wallpaper. There are two methods to
accomplish this ( that I am aware of ).

1) create a solid color bmp as a background image and set the transparency
key to match its color
2) specify the form's background color with a matching transparency key

Now my issues with both methods, but first it should be known that I have
set the forms to have no border or title bar and have implemented code that
allows me to click-and-hold anywhere ( with exceptions listed below ) on the
form and move it. The data actually displayed on the form is just text and
one rectangle, all drawn by me ( there are no controls on the form itself ).

1) I have two issues with this method, although it is what I'm prefering to
use at the moment. The first seems to be the discrepancy between how the
program is handled when the computer's Color Depth is 32bit or when it is
less than 32bit ( 16bit ). When the color depth is 32bit then I am able to
click on the entire area the form inhabits ( even that which is
transparent ) and move it, but if the color depth is less than 32bit (
16bit ) then only the drawn text or rectangle outline ( since it has no
fill ) can be clicked to drag the program around. Clicking on the
transparent areas just passes the click through the form to whatever is
below ( even when I know the form has focus ). I'd like to be able,
regardless of the desktop's color depth, to click anywhere within the form
area and move the application.

The second issue I have with this method occurs when I take my executable
and put it on another PC ( my PC is XP Pro, the other PC is XP Home.. Both
SP2 ). The problem is similar, but a little different. When the 2nd PC's
color depth is at 32bit, the transparency does not work. The green/lime (
that's the transparent color I'm using ) background shows. Needless to say
this is not acceptable. When I change the color depth to less than 32bit
( 24bit this time ), the transparency actually works, but I come across the
same issue of clicks on the transparent areas just passing through.

2) With this method I have not tried it on a 2nd PC yet ( I don't have it
available where I am atm ). Its basically the same "issue" as mentioned
above with color depth less than 32bit, except it does it with a color depth
of 32bit and 16bit. Clicks on the transparent areas just pass right
through. I'm tempted to just go with this method and possibly make one area
on the form that is meant to be used to drag it around ( similar to the idea
of the box that appears to move tables in MS Word ), but I'm hoping there's
a solution I'm unaware of before I do that.

Anyways, all of this brings up some interesting questions.

-What does color depth have to do with transparency handling?
-Does the version of XP ( Home or Pro ) handle transparency differently?

Probably some more questions also.

Not sure if it matters, but I'm doing all of this in C#.

So any ideas to get pass any of these issues?

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top