Using Win32 functions in Visual FoxPro Image Gallery
ScreenCapture Library (FLL) for Visual FoxPro
Mar 26, 2011.
Summary:
Captures images of VFP forms, other windows, and parts of a screen. Saves a captured image to a file - supported formats BMP, JPEG, PNG, TIFF, GIF (PDF coming soon) - , sends image to the clipboard, prints, or opens a preview.

Supports image scaling and clipping. Optionally prints a multiline annotation above a captured image. Allows storing metadata in captured files.


Regular price:
  Buy this solution for $15.00
Instant download link by email.

Price for subscribers:
Make payments with PayPal - it's fast, free and secure!   Buy this solution for $10.00
Instant download link by email.

Download demo
Contents
Usage
All Functions
Usage     ..top
Opening the library.
 
SET LIBRARY TO VfpScreenCapture.fll
*SET LIBRARY TO VfpScreenCapture71.fll  && CRT71 equivalent
 

Capturing a VFP form's image and saving it to a file.
 
sc_SetScale(75) && in percents, valid range 10 to 1000
sc_SetCaption( "Created: " + TRANS(DATETIME()) )  && optional description up to 1000 characters
sc_WindowToImageFile( thisform.HWnd, "screencapture.png" )  && bmp, png, jpeg, gif, tiff
 

Capturing a part of the VFP main window and placing it on the clipboard.
 
sc_SetClip( 50, 50, 700, 300 )  && left, top, width, height
sc_WindowToClipboard( _vfp.HWnd )
 

Capturing a form's image and sending it to printer.
 
* assuming that a form with this caption is running
hWindow = sc_FindWindowByText( "List of products" )
 
IF hWindow <> 0
    sc_SetCaption( "Follow up" )  && optional description
 
    sc_WindowToPrinter( hWindow ) && default printer
*    sc_WindowToPrinter( hWindow, "HP Officejet Pro L7700 Series" )
ENDIF
 

Saving captured image along with a metadata.
 
sc_SetMetaProperty( 0x010D, "Document name: screen capture" )
sc_WindowToImageFile( thisform.HWnd, "screencapture.jpg" )  && jpeg, png
 

Capturing a VFP control's image.
 
sc_SetOriginMode( 1 )  && 0-whole window, 1-client part
 
WITH thisform.Edit1
    sc_SetClip( .left, .top, .width, .height )
ENDWITH
 
sc_WindowToClipboard( thisform.HWnd )
 

Printing the whole screen using the default printer's current settings.
 
DECLARE INTEGER GetDesktopWindow IN user32
 
hWindow = GetDesktopWindow() && Windows Desktop
sc_WindowToPrinter( hWindow )
 
All Functions     ..top

sc_WindowToImageFile( nHWnd As Number, cFilename As String ) As Boolean
Captures the image of a window specified by a window handle. Saves a captured image to a designated graphics file assuming it bears a supported extension. Valid file types: BMP, PNG, JPG, TIF, GIF.

sc_WindowToPrinter( nHWnd As Number [, cPrinterName As String ] ) As Boolean
Captures the image of a window specified by a window handle. Sends a captured image to a printer. The default printer is used if the cPrinterName is omitted.

sc_WindowToClipboard( nHWnd As Number ) As Boolean
Captures the image of a window specified by a window handle. Places a captured image on the clipboard.

sc_SetScale( nPercent As Number ) As Boolean
Scales a captured image. Measured in percents. The valid range is from 10 to 1000. The default is 100%.

sc_SetCaption( cCaption As String ) As Boolean
A description to be displayed above subsequently captured images. Send an empty string to clear.

sc_SetBorder( lBorder As Boolean )
Places a thin border around a captured image.

sc_SetClip( nLeft, nTop, nWidth, nHeight ) As Boolean
Crops a captured image except a given rectangle. Call SC_RESETCLIP() to cancel a image cropping.

sc_ResetClip()
Cancels captured image cropping. See SC_SETCLIP.

sc_SetSafetyOff()
Automatically overwrites existing file when SC_WINDOWTOIMAGEFILE() is called.

sc_SetSafetyDefault()
Based on a current SET("Safety") setting, displays a dialog box before overwriting an existing file when SC_WINDOWTOIMAGEFILE() is called.

sc_SetOriginMode( nOriginMode As Number )
Sets the capture origin. Choose 0 for a whole window, or 1 for the client area. See "Capturing a VFP control's image" usage example.

sc_FindWindowByText( cWindowCaption [, lAllProcesses [, lCaseInsensitive ]] ) As Number
Returns window handle for a window specified by the caption. By default searches through windows belonging to the current process only. When lAllProcesses=.T., searches through all windows. Set lCaseInsensitive=.T. for case-insensitive search.

sc_SetMetaProperty( nPropertyTag As Number, cPropertyValue As String ) As Boolean
Sets a meta property to be written to captured images in subsequent SC_WINDOWTOIMAGEFILE calls. Note that meta properties are mainly supported by JPEG format, and to lesser extent by PNG and TIFF formats. Bitmaps and GIFS do not support meta properties.

sc_RemoveMetaProperty( nPropertyTag As Number )
Removes a single property from the list of meta properties to be written to captured images in subsequent SC_WINDOWTOIMAGEFILE calls.

sc_ClearMetaProperties()
No meta properties will be written to captured images in subsequent SC_WINDOWTOIMAGEFILE calls.

sc_OpenFile( cFilename As String ) As Boolean
Opens a specified file using default application the Windows assigned for this file type.

* * *
Note that any SET function affects all subsequently captured images, until the next time this function is called, or the library is reopen. For example, when the border is set on, all images captured afterwards will have a border.

* * *
Pending functions.

sc_ClipboardToImageFile( cFilename As String ) As Boolean
Saves CF_DIB content of the clipboard to a specified image file. A CF_DIB content must exists. See SC_CLIPBOARDHASIMAGE(). Status: ready for the next release.

sc_ClipboardHasImage() As Boolean
Returns .T. when the clipboard has image content (CF_DIB). Status: ready for the next release.

sc_MoveToForegound( nHWnd As Number )
Moves a given window to the foreground. Status: ready for the next release.

sc_WindowToPDFFile( nHWnd As Number, cFilename As String ) As Boolean
Captures the image of a window specified by a window handle. Saves a captured image to a designated PDF file. Based on Haru PDF Library. Status: working prototype, to be tested.
Mar 26, 2011.
Regular price:
  Buy this solution for $15.00
Instant download link by email.

Price for subscribers:
Make payments with PayPal - it's fast, free and secure!   Buy this solution for $10.00
Instant download link by email.


Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Google
Advertise here!