Problem with Shaped Windows Forms

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Voyager (husoway_at_hotmail.com)
Date: 03/06/04


Date: 5 Mar 2004 23:57:10 -0800

Hi, I have a problem driving me nuts!
Visual Studio has a doc that explains how to create a shaped window.
I followed the doc exactly yet the purple color that I choose as my
transparent color, which IS also on the bitmap I used as the
background of my form will not show as transparent. The purple shows
instead of being tansparent. This is a fairly simple process yet I
cannot get it to work.
Any ideas? Here are the steps I followed, in their example they set
blue to be trnsparent. (Plz note, my problem is not monitor related, I
know this).
PLEASE HELP!

In the Windows Forms Designer, click the form so that it has focus.
In the Properties window:
Set the FormBorderStyle property to None.
This property removes the title bar from the form

Set the BackgroundImage property of the form to the .bmp you created.
There is no need to add the file to the project system; this will be
done automatically when you specify it as the background image.
This property sets the bitmap image to be the background of the form.
(When used in tandem with the TransparencyKey property specified
below, this defines the shape of the form.)

Set the TransparencyKey property to the background color of the .bmp
file. In the case of the example above, you would set it to blue.
This property tells the application which parts of the form you want
to see through. (Effectively, we will "cut out" the desired shape of
the form from a rectangle.)

Note Monitors set to a color depth of greater than 24-bit can
display problems with certain parts of the form not being transparent,
despite setting of the TransparencyKey property. To avoid this
problem, ensure that the monitor's color depth is set to less than
24-bit in the Display control panel. When developing applications that
feature this transparency, keep in mind that you will have to make
your users aware of this issue.
Save the application. Run it by pressing F5.
Note that, at run time, your Windows Form now looks like your bitmap.
Also, notice that there is no title bar available for easy moving or
closing of the application. Press ALT+F4 to close your application and
continue development.



Relevant Pages

  • Re: about transparent window
    ... This is particularly true for window size and position. ... Since you want to apparently compute a bitmap as large as your client area, ... SetLayeredWindowAttributes API,but control is also transparent same window,I ...
    (microsoft.public.vc.mfc)
  • Re: HPEN and Rectangle() on Contantly refeshing window object
    ... Indeed I cannot get to the video rendering at this time (although in the ... this idea about creating a transparent window (as opposed to the ... able to draw a rubberbanded rectangle around an area within this screen. ...
    (microsoft.public.vc.mfc)
  • Re: Transparent GIF Images, Button Colors
    ... I was describing transparency issues. ... window styles that CE imposes. ... these "stuck" styles is that the window underneath ... the transparent part doesn't get repainted in the ...
    (microsoft.public.pocketpc.developer)
  • Re: spaceships, terminology, windows
    ... The join between opaque metal and transparent metal ... thick the hull is. ... thick you're not going to get as high resolution as with a decent video ... It's not practical to have a window for looking at eyeball-visible ...
    (rec.arts.sf.composition)
  • Re: Help with VW Event Handling
    ... I was wrong about the lastControlObject being set to a widget from ... for my transparent window and got something running. ... active controller and not generating duplicate ...
    (comp.lang.smalltalk)