 |
| Creating irregularly shaped FoxPro form using transparency color key |
User rating: 10/10 (1 votes) | |
|
|
 |
 |
Versions: click to open |
 |
|
 |
 |
| Before you begin: |
 |
Download this image file before testing the code sample:

The SetLayeredWindowAttributes function can be used to define the transparency color key for the top-level FoxPro form. That means all areas on the form with this color, including native windowless FoxPro controls, become transparent.
Such transparency is not only visual. The masked area is also transparent for the mouse events. Those events are directed to the windows below. It looks like the mouse transparency is provided only for bitmap images, not for gifs and jpegs.
Bluish background color on this image has value of RGB(0,121,197), which is passed as the transparency color key to the SetLayeredWindowAttributes function.
See also:
Round FoxPro form
How to draw a custom Window Caption on FoxPro form
A way to make a transparent area in a form -- a hole in the form
Semi-transparent form
|
 |
 |
| |
| |
Members area. Log in to view this example. |
|
| |
|
|
|
|
|
 |
User rating: 10/10 (1 votes) | |
| 3039 bytes Created: 2001-07-12 12:00:00 Modified: 2012-03-17 21:57:36 Visits in 7 days: 185 |
|
 |
 |
| Listed functions: |
 |
|
 |
 |
| My comment: |
 |
It is important to have the background perfectly solid. Conversion to JPEG may create color artefacts because of the way the image is compressed with removing supposedly unnecessary part of it.
Observe the difference between the masked bitmap image and originated from it masked JPEG image. As I mentioned above, only bitmap images provide mouse event transparency.

Note that the Region API functions are still used to hide the frame of the form.
This combined approach can create irregular forms effortlessly, if compared to using solely Region API calls. After all, truly irregular forms may not be easily shaped with a combination of regions.
The SetLayeredWindowAttributes requires at least Win2K, and works with top-level forms only (ShowWindow=2). Also a twinkling black border may appear around the the form when it is being moved.
* * *
.NET WinForm implementation:

* * *
.NET WPF implementation is as brief as it is simple. In this case the background of PNG image must be transparent.

|
 |
 |
| Word Index links for this example: |
 |
|
|
 |
 |
| Translate this page: |
 |
|