General information
Category:
Windows API functions
Title:
PRINT SCREEN - Figured Out A Way!
I figured out a way to emulate a PrintScreen for VFP.
First, make printscr.prg execute when the user pushes a hotkey:
i.e.:
ON KEY LABEL ALT+F12 DO printscr
Then, create a report form which simply displays a bitmap from a field called "screen_capture.screen".
The code will programmatically copy the active window to the clipboard, copy it to a general memo field, and then print the captured screen through the report form.
This only works on modeless forms where the "Edit" menu pad is accessable.
--Shawn
--------------------------
printscr.prg:
--------------------------
LOCAL cAlias
cAlias = ALIAS()
** Declare Win32Api Command:
DECLARE INTEGER keybd_event IN Win32API ;
INTEGER, INTEGER, INTEGER, INTEGER
** Execute an alt-printscreen to capture active window:
keybd_event(44, 0, 0, 0)
** On the report form we print a bitmap from a field so create a cursor:
CREATE CURSOR screen_capture (SCREEN G)
APPEND BLANK
SELECT(cAlias)
** Programmatically copy the bitmap outside of the visible work area so user
** doesn't see whats going on. Note: The Edit menu pad must be enabled.
DEFINE WINDOW screen_capture FROM 200,200 TO 203,203
MODIFY GENERAL screen_capture.screen NOWAIT WINDOW screen_capture
KEYBOARD "{CTRL+V}{CTRL+W}" CLEAR
** Release the temporary window:
RELEASE WIND screen_capture
** We need this or VFP5 will "get ahead" of itself and not copy anything:
DOEVENTS
** Finally, print the screen on a report form:
IF !EMPTY(screen_capture.screen)
SELECT screen_capture
REPORT FORM reports\printscr.frx TO PRINTER NOCONSOLE
ELSE
WAIT WINDOW "Sorry, you cannot do a PrintScreen of this form." NOWAIT
ENDIF
USE IN screen_capture
SELECT(cAlias)
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only