Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rich text
Message
From
04/08/1999 05:59:34
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Title:
Miscellaneous
Thread ID:
00249538
Message ID:
00249617
Views:
17
>Can anyone recommend a Richtext control that prints. I have tried everything I know to make the MS Richtext control print using the VFP report writer.
Mark,
As far as I remember this code was posted by Christof Lange weeks ago (sorry if wrong person is credited) :
function RichTextPrint
*==================================================
* 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
IF PCount() < 3
	tcDoc = toRTF.SelRTF
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 = ToInt(12)+ToInt(lnDoc)+ToInt(0)
	StartDoc( lnHDC, lcStruct )
	StartPage( lnHDC )
	toRTF.SelPrint( lnHDC )
	EndPage( lnHDC )
	EndDoc( lnHDC )
	DeleteDC( lnHDC )
	HeapFree(lnHeap, 0, lnDoc)
	HeapDestroy(lnHeap)
ENDIF

*==================================================
* Convert into an integer
*==================================================
FUNCTION ToInt
PARAMETER tnValue
PRIVATE cString, nT
cString =''
FOR nT = 1 to 4
	cString = cString +Chr(tnValue%256)
	tnValue = Int(tnValue /256)
ENDFOR
RETURN cString
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform