google, yahoo, vista have all got them. now so has visual foxpro and you. i am talking about those little apps called widgets that you can use to clutter your screen with.
using png graphics that are supported by vfp is one way to create very cool widgets. i have described here how png's with an alpha mask can be used to show some cool glass-like pseudo "forms".
now i will describe here how this can be extended to creating glass widgets. while we have always had widgets, and have used them, the technique described here will give you a draggable glass widget, similar to vista. and best of all this can be achieved in xp!
for this post i will create a clock widget. you can download the complete source from the attachment at the end of the post.
the clock is a simple vfp class that will autorun when dropped on a form and the form run. the trick behind the glass effect is in the background png image of the class:
while it looks like a plain old black & white graphic, it contains an alpha channel mask embedded in it. the png format supports saving this mask in the image and the vfp image object respects and uses this mask. if you open this image in a paint program that supports masks, like photoshop, (i use paint shop pro) then you can see the mask.when this image is loaded into a vfp image object, the mask takes effect and makes certain areas transparent based on the information in the mask.
thus all it takes is to insert an image object into a transparent container and the effect is complete. the clock class just adds the code for the date, year and movement of the hands. there is also code in the image class to allow dragging the container, so that the clock can be moved.check out the code in the mouse events of the image object class.
below you can see the glass outer area that allows the background image to seep through. this area is also used to drag and drop the clock to a new location. the colours you can easily change since i have included the full source. run the exe and drag the clock around. careful when you drop it though, as we dont want to break the glass!
here is the clock running inside a top level form.
c'mon get busy making your own widgets for vfp!