KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Saving a screenshot of a form to a file
PRODUCT: 4D | VERSION: 12 | PLATFORM: Mac & Win
Published On: May 27, 2011

In 4D v12 12.2 a new command FORM SCREENSHOT has been introduced. This command creates a picture from a form and comes in two flavors. See the Language Reference page for the FORM SCREENSHOT for full details.

With this command, it is now possible to create a simple "save to file" option that saves a form to a file with just a few lines of code. Here is a code sample that will do this:

//get the screenshot
C_PICTURE($image)
FORM SCREENSHOT($image)

//do something with it
$filePath_t:=System folder(Desktop)+"capture.jpg"
WRITE PICTURE FILE($filePath_t;$image)


Note that when the FORM SCREENSHOT command is executed, the image generated will display all the form objects with their current values. Also this form of the command can only be used with Input Forms.

If all you need is an image of a form, this is a quick and easy alternative to using any print commands.