Emulating the XP Shutdown Effect in VFP9 forms with GDI+
Everyone who has used XP would have seen the effect produced when a user opts to shutdown Windows XP. To see it you click the "Start" button and then select ShutDown, which brings up the windows shutdown dialog similar to the one below.
The question is why would anyone click "Start" when they want to "Stop"? But that is another story...

You may have also noticed that windows slowly fades the coloured background down to grey, leaving the coloured dialogbox to appear more prominent. The colour of the desktop is restored if the user cancels this operation.
This same effect is possible in VFP forms and applications by using the GDI+x classes found on codeplex.
The class I created will do this for you for any form you drop it on, and call its methods. This class (download link below) uses the Imgcanvas object so to use it you will need to download the GDI+x classes.
Usage is extremely simple. You just drop it on the main form of a SDI or add it to _screen. When you need to produce the effect, you just call its SHOWLIGHTBOX() method and to remove the effect call the HIDELIGHTBOX() method. As calling sample is shown below which could be added to an Exit or Quit button:
bb = ThisForm.bbGdilightbox1.Showlightbox()
IF MESSAGEBOX("Are you sure you want to Quit?",308,"GDI+X Lightbox",0) = 7
bb = ThisForm.bbGdiLightbox1.Hidelightbox()
RETURN
ELSE
ThisForm.Release
ENDIF
Basically what happens when the ShowLightbox method is called is that using GDI+ an image of the mainform is captured, the lightbox class expands to overlay the whole form and the image is painted on the imgcanvas. A timer is kicked off in the background and the class returns control to the code.
The timer in the background increments a variable and calls the imgCanvas.Draw. The variable affects the way the ColorMatrix is created and this changes the colours of the screen image. With repeated calls the colour is "faded" till the image is grey. The timer then stops.
To restore, the class is just made invisible again.
The code to produce this effect comes from an article by Cesar in the UT mag. without which this class would not have been possible.
A sample form where you can test this as well as a pseudo messagebox form is also included in the download for this article. Just make sure you have the GDI+x classes, run SYSTEM.APP and then run the form:

Sample form with coloured background and VFP controls.
Click the "Exit" button to see the effect as the messagebox appears and the background slowly fades to grey.

Sample form with the form and controls faded to grey.
Complete source code is provided for anyone to modify as they please. Enjoy.
Update: Since I do not include the gdiplusx.vcx (as this must be downloaded from the VFPX site) and since I have subclassed the imgcanvas class found in the gdiplusx.vcx classlibrary, you need to resolve the link to the class yourself.
Just open the form in VFP and when it asks you for the Imgcanvas navigate to the gdiplusx.vcx on your computer where you will find the imgcanvas class. The form will then resolve the location correctly. Save the form, set the default path to the directory where the form is (to find the images) and then run the form.
Unfortunately this would happen since I don't supply the gdiplusx.vcx and I don't know where a user might have stored it. Thanks to Mike S for pointing that out.
Comment Notification
If you would like to receive an email when updates are made to this post, please register here
Subscribe to this post's comments using