in my earlier post i showed a lightbox class done in vfp.

mike s posed a problem:

i've got one issue with it when placed on a vfp form that contains an activex control (ms webbrowser). the lightbox is not able to capture the contents of the activex, only the hosting vfp form. is there anyway to have it include the activex content as well?

that got me thinking because i did not provide for activex and as we all know, they always insist on being the topmost item on a vfp form. the only way to hide them is to set them as invisible.

but that would leave the screen looking like crap.

the idea that came to me was to "pull the wool over the user's eyes" so as to say. hide the activex but make it appear that it is still visible.

if you're a vfp developer and are looking for gdi+x there is no other place better than cesar's blog. so the rescue comes gdi+x and after browsing cesar's site a while i found what i was looking for. thanks cesar. you are the best.

so i adapted the class and to use the new version you must have the gdi+x classes from codeplex, as it now uses from the gdi+x classes. place this in along with the files from the download link below.

the idea i had is this. as part of the lightbox appearing, i first iterate through the controls of the form looking for any activex objects. if i find any, i add an image object to the form, then grab a partial screen capture of the activex, load that into the new image object, hide the activex and show the new image instead.

with vfp and gdi+x classes this is fast.

each image object so added is stored in a class array for cleaning up later.

so the call to lightbox and everything else is the same. i just added a couple of methods and properties to handle activex.

if the user clicks no on the messagebox, then i again iterate through all the activex objects and make them visible and removeobject all the image objects added earlier. a call to refresh refreshes the objects.

here is a form with 2 activex objects, a ma datetime picker and a web browser control.

and here is the same form after the user has clicked the lightbox button

you cannot tell that the activex are really images now can you?

1. you must have the from the gdi+x classes. this class will not work without it.
2. due to calling refresh, the web browser control wants to reload the site again. that cannot be helped since otherwise you will find that the area covered by it will not refresh when visibility is toggled by the class.

thanks also mike s for posing the question and getting me thinking.


update: 14th sep 2008
some folks are still having problems which stem from 2 things.

1. they are using vfp9sp1 so the pictureval used in the class does not work on png's. i have permanently changed the mask to a tiff,

2. i  have also included the tiff mask file in the zip. just change the property maskfile to point to the full path + filename of the mask file whereever you store it.

3. they have set deleted off so cannot see the mask. i have "packed" the class to remove the deleted records and also added code in the init to set/reset the environment to take care of that.

please let me know if there are any other  problems.

update: 02 feb 2009

it was reported on foxite that the above class was causing errors. since it was designed for activex, if used on a form with no activex, it gave an error.

the error has been fixed in this version and now this class can be used with forms both with and without activex.

 final update

it has come to my attention that if a user sets the borderstyle = 1 or 0 or sets the titlebar off in a form the class errors.

therefore the following changes have been made to update this class:

1. the form can now have any borderstyle

2. titlebar can be off or on

3. removed all reference to thisform from class. now uses the parentclass so drop it on a form only.

4. removed the code that creates multiple screen dumps of partial objects. now only one dump is stored of the whole screen.

5. includes the ability to drill down to activex stored in containers and pageframes.

note: i have not tested this with _screen. you will need to test and modify the code as needed.


i forgot to include the other files. here they all are in the single zip.

6 Responses to VFP Lightbox Class – Now Activex Friendly

Leave a Reply

Your email address will not be published. Required fields are marked *