Some users need to make some screenshots from his applications so I wrote this little component to make it from Xailer.
The properties of this control:
PROPERTY cFilename, optional, name to save the screenshot.
PROPERTY lClientArea, captures the client area or all the window’s content.
METHOD Capture( oControl | hWnd ), Xailer control or a window handle and takes the screenshot in memory.
METHOD Save( cFilename ), saves the screenshot as a bitmap. If cFilename is not passed, it uses the name assigned to the cFilename property.
METHOD CopyToClipboard(), puts the capture into the clipboard in bitmap format.
METHOD HardCopy( lPreview, cTitle ), send the capture to the printer or to preview. Credits to Bingen.
Some samples will help to understand how to use it.
In the first sample we are going to capture the client area from the sample form and save it as “c:test.bmp”
METHOD Button1Click( oSender ) CLASS TForm1 WITH OBJECT TCaptureBitmap():New() :cFilename := "c:test.bmp" :lClientArea := .T. :Capture( Self ) :Save() END RETURN Nil
In this one, we capture the desktop and save is as “c:desktop.bmp”
METHOD Button2Click( oSender ) CLASS TForm1 WITH OBJECT TCaptureBitmap():New() :Capture( GetDesktopWindow() ) :Save( "c:desktop.bmp" ) END RETURN Nil
And in this, we capture the form and send it to the preview:
METHOD Button2Click( oSender ) CLASS TForm1 WITH OBJECT TCaptureBitmap():New() :Capture( Self ) :Hardcopy( .T., "Taking a screenshot from Xailer" ) END RETURN Nil
In the next release, I will add support to save the screenshot as JPEG, PNG and other image formats.
The ZIP bmpcap.ZIP includes the library ready to be used in the IDE.
NOTA: This library is to be used with version 1.7 or newer.