3

The LA Fox Developer Newsletter
January 1998
The Latest VFUG Stuff
Below are some of the VFUG’s latest tips and tricks. These are
so fresh, they may not even be loaded into the FAQ section by
the time you read this!

Child and Parent Form Print Function

*Use this procedure as PrintForm( Thisform ) or PrintForm(
_Screen )
Child and Parent Form Print function*
‘Author: Maunclo Atanache G.
Date : December 10/97
Parameters : oObjeto is an object FORM, for example THISFORM,
ACTIVEFORM, _SCREEN


Procedure PrintForm

IParameters oObjeto
LOCAL cAlias, lUsado

‘Save current alias
IF USED(ALIASO)
cAliasALlAS()
lUsado=.T.
ELSE
IUsado.F.
ENDIF

*
Put image in clipboard
If ITomaFoto( oObjeto)
Ret’irn
Endif
*
Create a cursor for store the image, uses a general field
CREATE CURSOR Foto_Pantalla (SCREEN G)
APPEND BLANK
IF IUsado
SELECT(cAlias)
ENDIF

*
Copy the image from the clipboard to the general field
DEFINE WiNDOW Ventana FROM 1,1 TO 4,4
MODIFY GENERAL Foto_Pantalla.SCREEN NOWAIT WiNDOW Ventana
KEYBOARD “{CTRL+V}{CTRL+W}” CLEAR
RELEASE WIND Ventana

DOEVENTS

*
Must create a report named prtform with an otecontrol
*
and SCREEN as Source
IF !EMPTY(FotoPantalla.SCREEN)
SELECT Foto_Pantalla
REPORT FORM prtform.frx TO PRINTER NOCONSOLE
ELSE
WAIT WINDOW “Sorry, Can’t print”
ENDIF

*
Close the cursor
USE IN Foto_Pantalla

*
Restore current alias
IF lUsado
SELECT(cAlias)
ENDIF

Return
* Author Mauricio Atanache G.
* Date : December 10197
* This function puts the image of the form in the clipboard, you can
use
*
it to send form images to other aplications as Word etc.
* Also you can modify this function to print or copy any object on
*
screen.
* Parameters : oForm is an object FORM, for example THISFORM,

ACTIVEFORM, _SCREEN


Function TomaFoto
IParameters oForm
Local nHwnd, tnHwnd, hDC, hDC_Mem, flBitMap, hPrevBmp
*
Must use the Foxtools library, somewhere.
Declare integer FindWindow in Win32Api String cClassName, String
cWindName
Declare integer GetDC in Win32Api integer nhwnd
Declare integer CreateCompatibleDC in Win32Api integer nhcd
Declare Integer BitBIt in Win32Api Integer hDestDC, Integer x,
Integer y,
Integer nWidth, Integer nHeight, Integer hScrDC,
Integer xsrc, Integer ysrc, Integer dwRop
Declare Integer SelectObject in Win32Api Integer hDC, Integer
hObject
Declare Integer CreateCompatibleBitmap in Win32Api Integer hDC,
Integer nWidth,
Integer nHeight
Declare Integer SetClipboardData in Win32Api Integer nFormat,
Integer hObject
Declare Integer DeIeteDC in Win32Api Integer hDC
Declare Integer PeleaseDC in Wln32Api Integer nwnd, Integer hdc
Declare Integer DeleteObject in Win32Api Integer hDC
Inwhandle = _WFindTitl(oForm.Caption)
nHwnd = _WhToHWnd(Inwhandle)
hDC = GetDC( nHwnd)
hDC_Mem = CreateCompatibleDC( hDC
hBitMap = CreateCompatibleBitMap( hDC, oForm.Width,
oForm.Height)

If hBitMap#0
hPrevBmp = SelectObject( hDC_Mem, hBitMap
BitBIt( hDC_Mem, 0, 0, oForm.Width, oForm.Height, hDC, 0, 0,
13369376
If OpenClip( nHwnd )
EmptyClip()
SetClipboardData( 2, hBitMap)
CloseClip()
Else
MessageBox( ‘Error opening the clipboard’, 48, ‘Mes-
sage’ -
Endif
Else
MessageBox( ‘Error creating bitmap’, 48, ‘Menssage’
Endif

DeIeteDC( hDC_Mem)
ReleaseDC( nHwnd, hDC
Return .t.


e-mail : dsmauriclo@Hotmall.com
Address : Crr 19 No. 75 u 20 of 401, Bogotss u Colombia
Telephone : 3460746 - 3460673
Page 3

3