Mike Yearwood
Toronto, Ontario, Canada
Information générale
Catégorie:
Fonctions Windows API
>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)
That's brilliant! Does a similar method work in VFP 3?
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement