Using the Alpha Channel in Visual Foxpro Images
Using the Alpha Channel in PNG images can result in some very interesting and pleasing effects.
I have been working on some pseudo forms using Alpha Channel masks in PNG images with some very pleasing results. I was not aware that VFP could handle the Alpha channel masks of PNG's so decided to give it a try.
Updated on 12/09/2006 (see below)
I created the images in Paint Shop Pro but any image application like Photoshop etc that can create masks will do. When loaded into a VFP image object these images displayed very interesting effects, so I decided to spend some time exploring this aspect and the following screens are what I came up with. The Titlebar.png is used for the titlebar, mainform.png is used for the main form area. I added the Vistabuttons.bmp and placed invisible command buttons over them for the actions. All are placed into a transparent container into VFP image objects and the other objects like labels, textboxes etc are placed on top. They can be inatantiated using ADDOBJECT( ) onto the form. The images can be saved by right clicking and SavePictureAs.
Titlebar.png

Mainform.png

VistaButtons.bmp

The "forms" are classes with all objects inserted into a transparent container. Once that is done each "form" can be instantiated like any other class.
I say "form" because these are not real forms and do not have the normal form methods, events etc. They are just containers made to look like forms, and can be instantiated in a SDI (Top Level) form. They could be used for data entry or even just for messageboxes.
Here is a form with different objects. The "form" can actually be moved around like a normal form. You can easily see the transparent effect obtained, with the background showing through the title and borders but NOT through the central area. To the right are normal VFP objects placed on the SDI, just to show the difference. Notice the background is visible through the Title bar as well as the borders.
Click any image for a larger view.

This next image shows the form has been moved to partly cover the objects on the right, The Text from those objects is clearly visible through the "form" titlebar.

The final image shows the transparent effect achieved, while keeping the main form and objects opaque.

To achieve these effects took about 10 minutes. Less, now that I know how to produce the masks and the effect that can be achieved. With a little more code these can be converted to very modern looking Vista Aero Glass like windows on a humble XP OS.
Now all that's left is for my friend Cesar Chalom to come up with a way of doing this on the fly using GDI+....
Ain't Fox cool?
Update - 12th Sept 2006
Cesar has very kindly provided the code to generate the PNG images on the fly. You can get it here:
http://weblogs.foxite.com/cesarchalom/archive/2006/09/12/2445.aspx
This line of code can be changed to whatever size you want. The size here is 300w X 270H
loBitmap = .Bitmap.New(300,270)
Also the central opaque area colour can be changed here:
* Draw the yellow rectangle
loGfx.FillRectangle(.SolidBrush.New(.Color.FromRGB(254,254,228)), 10,9,278,249)
Remember to change the last 2 values to suit your new size - ,278,249)
All that's left now is for Cesar to show us how to make the transparent green PNG. I think it can be done in this line here, by changing the last 3 numbers which is the RGB.
* Make all image transparent
loGfx.Clear(.Color.FromARGB(0,0,0,0))
but I have to leave that to him.
Last tip is to set the image.BorderStyle = 1-Fixed Single. That will give us the opaque outline border of the "form". We are done here.
Thanks Cesar.You are Mr. GDI+ indeed.