Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PRINT SCREEN - Figured Out A Way!
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
PRINT SCREEN - Figured Out A Way!
Miscellaneous
Thread ID:
00024984
Message ID:
00024984
Views:
71
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
Map
View

Click here to load this message in the networking platform