Transparent Forms in Visual FoxPro Revealed
How it is done
My previous post was purposely vague as I wanted to stir some interest. Just describing the method used to achieve the effect would have been easy but would have ended the interest there.
Many readers “got it”. Some slightly differently to what I did but nevertheless there are many ways to skin a cat. Other’s just did not.
Anyway in this post I will describe the method used to achieve the semi - transparent form effect. I hope readers will think about the techniques used and come up with their own takes on this.
The main form is a SDI form with my “Outlook” navigation classes. Basically selecting an option by clicking the light blue buttons fills a tree view above with the screens available. Clicking one of these opens a window on the right where the action takes place. So far all this is standard. The SDI form has a large image as its background.
(Click on each image to see an enlarged version)

Just below the “Product Ordering” can be seen a red "X"This normally has Visible = .F and I use it as my marker.
For my child form, I created a form class and all the child forms inherit from this class. This form class is a normal form with the TitleBar = 0 and BorderStyle = 0 (no border). I then sized it to the correct size I required.
I opened the large background image and copied an area of it starting from the red "X" down to the bottom right. I now had an image smaller that the main image. I applied a white mask layer to it and adjusted the mask’s transparency, similar to what Word does when you create a watermark. I ended up with an image as below.

This I made the background of my form class. I had to manually adjust the size of the form till it was just the size of the image. Now I had a base class that I could use for all my forms. Here is one of the child forms in design time.

Each child form was then created as normal with objects and code added. The Click event of each item on the treeview opened the appropriate form.
In the INIT of the form class I added this code:
LPARAMETERS toForm
With ThisForm
* LabelX is the name of the Red “X”label Object.
.Top = toForm.LabelX.Top
.Left = toForm.LabelX.Left
ENDWITH
In the Click of the TreeView item the appropriate form is called like this:
DO Form MyChildForm With ThisForm NOSHOW
SHOW Window MyChildForm IN WINDOW Mainform
With the above code the child form appears in the correct place and will move if the main form is moved. Resizing is NOT allowed for obvious reasons. In testing I had to make slight adjustments to the red "X" so that the images aligned correctly.
The final effect can be seen in this screen dump below. I have purposely left a wider border around the child form so that the effect is more obvious.

This blow up of the form edge shows the effect:

This gives the impression that the child form is transparent and the image of the main form can be seen through it. The controls are opaque as they should be. This effect cannot normally be achieved in windows XP. It is only possible in Vista with new API’s.
Illusion Complete.
Viva La Fox!
Here is another link to a similar form which shows the effect.