Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Printing forms
Message
De
19/07/1998 22:12:11
Chris Crachiolo
Blackmoor Associates Incorporated
New York City, New York, États-Unis
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00116195
Message ID:
00119146
Vues:
26
Cool! Thanks!


>I think this is what you are looking for. It was developed by Gerry Schmitz and allows you to easily print just the active window. It uses DIBAPI32.DLL which is included with Microsoft's WinCap utility. You can find either on the MSDN CD that ships with Visual Studio (search for WinCap) or Microsoft's web site (search for DIBAPI32.DLL or WinCap). Once you have the DLL it is easy to build a routine that will print the active form. Here is the code I'm just added to my form class.
>
>
>*!* METHOD PrintForm
>LOCAL lnHWnd
>LOCAL lcJobName
>LOCAL lnRetVal
>
>DECLARE INTEGER GetFocus IN WIN32API
>DECLARE INTEGER PrintWindow IN DIBAPI32 ;
>	INTEGER HWnd, ;
>	INTEGER fPrintArea, ;
>	INTEGER fPrintOpt, ;
>	INTEGER wxScale, ;
>	INTEGER wyScale, ;
>	STRING @ szJobName
>	
>*!* Print entire window
>#DEFINE PW_WINDOW 1
>*!* Print just the client area of the window
>#DEFINE PW_CLIENT 2
>
>*!* Fit to page
>#DEFINE PW_BESTFIT 1
>*!* Stretch to fill page
>#DEFINE PW_STRETCHTOPAGE 2
>*!* Scale by wxScale and wyScale
>#DEFINE PW_SCALE 3
>
>lnHWnd = GetFocus()		&& Get handle to active window
>lcJobName = THISFORM.Caption + CHR(0)
>
>lnRetVal = PrintWindow( lnHWnd, PW_WINDOW, PW_STRETCHTOPAGE, 0, 0, @lcJobName)
>IF lnRetVal != 0
>        IF lnRetVal != 6		&& 6 = User canceled printing
>		= MESSAGEBOX("Unable to print the form" + CRLF + ;
>				"PrintWindow returned " + STR(lnRetVal), ;
>			MB_ICONEXCLAMATION + MB_OK, ;
>			"ERROR")
>	ENDIF
>ENDIF
>RETURN
>
>
>Besides printing the form the DLL provides functions to save the form as a BMP. Great for documentation.
>
>
>*!* METHOD SaveAsBitmap
>LOCAL lnHWnd	&& Window handle
>LOCAL lnHBitmap && Handle to bitmap
>LOCAL lcFileName	&& Name of file
>
>LOCAL lnRetVal 	&& API call returned value
>
>DECLARE INTEGER GetFocus IN WIN32API
>DECLARE INTEGER CopyWindowToDIB IN DibAPI32 INTEGER hWnd, INTEGER fPrintArea
>DECLARE INTEGER SaveDIB IN DibAPI32 INTEGER hBitmap, STRING @ cFileName
>
>#DEFINE PW_WINDOW 1
>#DEFINE PW_CLIENT 2
>
>lnHWnd = GetFocus()		&& Get window handle for form
>lcFileName = PUTFILE("Save as Bitmap", THISFORM.Caption + ".BMP", "BMP")
>IF EMPTY(lcFileName)
>	RETURN
>ENDIF
>
>lnHBitmap = CopyWindowToDIB(lnHWnd, PW_WINDOW)
>IF EMPTY(lnHBitmap)
>	= MESSAGEBOX("Unable to create Bitmap from form", ;
>				MB_ICON_EXCLAMATION + MB_OK, ;
>				"ERROR")
>	RETURN
>ENDIF
>
>lnRetVal = SaveDIB(lnHBitmap, @lcFileName)
>IF lnRetVal != 0
>	= MESSAGEBOX("Unable to save the bitmap as: " + lcFileName + CRLF + ;
>			"PrintDIB returned " + STR(lnRetVal), ;
>		MB_ICONEXCLAMATION + MB_OK, ;
>		"ERROR")
>ENDIF
>
>RETURN
>
>
>If you want to print or save the entire VFP screen just substitute the MainhWnd() function from FoxTools for the call to GetFocus().
"Ignorance more frequently begets confidence than does knowledge."
-- Charles Darwin
"I am invincible! Invincible...OWWWWWWWW!"
-- Homer Simpson
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform