Information générale
Catégorie:
Contrôles ActiveX en VFP
Jason,
I'm not sure what the custom object definition your using looks like, but I was wrestling with the same problem until Christof Lange supplied this code (works like a charm):
Call it as such: =PrintRTF(ThisForm.RTFControl,GETPRINTER(),ThisForm.RTFControl.RTFText)
PROCEDURE PrintRTF
*==================================================
* Print the text of a RichText control
*==================================================
LParameter toRTF, tcPrinter, tcDoc
*-----------------------------------------------
* Declare some DLLs
*-----------------------------------------------
Declare Integer StartDoc in Win32Api ;
Integer, String
Declare Integer StartPage in Win32Api integer
Declare integer EndPage in Win32Api integer
Declare integer EndDoc in Win32Api integer
Declare Integer CreateDC in Win32Api ;
String, String, Integer, Integer
Declare Integer DeleteDC in Win32Api Integer
Declare Integer HeapCreate in Win32Api ;
Integer, Integer, Integer
Declare Integer HeapDestroy in Win32Api Integer
Declare Integer HeapAlloc in Win32Api ;
Integer, Integer, Integer
Declare Integer HeapFree in Win32APi ;
Integer, Integer, Integer
Declare lstrcpy in Win32Api Integer, String
*-----------------------------------------------
* Choose a printer
*-----------------------------------------------
Local lcPrinter
If PCount() < 2
lcPrinter = GetPrinter()
Else
lcPrinter = tcPrinter
Endif
*-----------------------------------------------
* Print
*-----------------------------------------------
Local lnHeap, lnDoc, lcStruct, lnHDC
If not Empty( lcPrinter )
lnHDC = CreateDC("WINSPOOL",lcPrinter,0,0)
lnHeap = HeapCreate(0, 8192, 8192)
lnDoc = HeapAlloc( lnHeap, 0, Len(tcDoc)+1 )
lstrcpy( lnDoc, tcDoc )
lcStruct = This.ToInt(12)+This.ToInt(lnDoc)+This.ToInt(0)
StartDoc( lnHDC, lcStruct )
StartPage( lnHDC )
toRTF.SelPrint( lnHDC )
EndPage( lnHDC )
EndDoc( lnHDC )
DeleteDC( lnHDC )
HeapFree(lnHeap, 0, lnDoc)
HeapDestroy(lnHeap)
Endif
Précédent
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