Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Printing an RTF file
Message
From
22/06/2001 09:32:59
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
22/06/2001 08:47:19
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00522361
Message ID:
00522393
Views:
14
>Anyone knows how to print an RTF file ? MS's RTF control should be able to do it but it seems VB oriented.
>Just want to print it, don't need to see it, so don't necesarily need the RTF control ...

Pascal,
If you mean to directly print from an RTF control on form then :
-Add CommonDialogs control to form

*CommonDialog.Init
this.Flags=0x0100

*Print command
This.Parent.CommonDialog.ShowPrinter
This.Parent.rtf.SelPrint(This.Parent.CommonDialog.hdc)

If you mean to print one from file then code is different. As I remember this was from Cristof Lange :
*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,-1 )
    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
If you mean to print in a report then Thread #306844 might help.
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