Welcome to Foxite.COM Community Weblog Sign in | Join | Help

Bernard Bout

May the Fox be with you...

<August 2006>
SuMoTuWeThFrSa
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789

Post Categories

Navigation

Some VFP links

Others...

Archives

Who links to this site?

Hey There!!!

Syndication




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.

Published Sunday, August 27, 2006 2:15 PM by bbout

Comments

# re: Transparent Forms in Visual FoxPro Revealed @ Monday, August 28, 2006 12:39 PM

Hi,
how can i test this solution,
would you like to share this with me

Thanks
soykan@soykansoft.com

You can follow the instructions in the post and create your own form. Then you run the form -  that is how you test the solution.

 

Soykan OZCELIK

# re: Transparent Forms in Visual FoxPro Revealed @ Thursday, August 31, 2006 1:02 AM

Hi, this screen looks amazing. where  can i  get the  "outlook" class

You can get an outlook class here:

http://weblogs.foxite.com/emersonreed/archive/2006/08/21/2291.aspx

Similar but not the same as mine.

 

Jimmy Alcala

# re: Transparent Forms in Visual FoxPro Revealed @ Thursday, August 31, 2006 4:20 AM

Hi Bernard, Great tricks!

I've one about this that want share to get the same effect but for any image and without cutting/editing the original image:

-Make one white bitmap just enough big (1024x768)
-Make one mask of the same size, but with a matrix of pixels white and black (like a chess board)
-Put an image control on the transparent-desired region and set it with the white bitmap with Stretch=0

Hope it likes you.

I know about that. What you mean is something like this:

I am using a similar effect in another case. However two things. You don't need a mask. Just a checkeredboard bitmap. Mine is Light Yellow and white. The white becomes transparent giving the transparent effect.

Secondly, this is not very useful when you have 1 SDI form set as AlwaysOnTop and open other forms inside this. Then the transparent efffect cannot be achieved with this method. But the idea can be developed for other effects as well.

Fernando D. Bozzo

# re: Transparent Forms in Visual FoxPro Revealed @ Tuesday, February 13, 2007 1:15 PM

Hi, Bernard menu outlock you very cool and very is the best.

Arie

New Comments to this post are disabled
Powered by Community Server, by Telligent Systems