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.
"Rami Saad" - 29 Dec 2004 16:05 GMT
Hello,
Check out the following links:
http://www.c-sharpcorner.com/Code/2003/May/TransparentControls.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbtskgivingyourcontroltransparentbackground.asp
http://support.microsoft.com/default.aspx?scid=kb;en-us;867631
Hope these help you solve your problem.
Regards,
Rami Saad
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC