Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Printing RTF
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00155810
Message ID:
00155940
Vues:
30
John,

Here's parts of 3 possible methods that I've clipped and saved to a file. I've not used the RTF control where it had to be printed so I've never actually done code to implement it.

---- Method 1
set classlib to dfwinapi
lcw = "C:\Program Files\Accessories\WORDPAD.EXE"
lcFile = "C:\Program Files\MSOffice\Office\Headers\APPTHDR.RTF"
x = create( "shellexecute", lcw, "", '/p "' + lcFile + '"' )
? x.execute()

----- Method 2
from Christof

*==================================================
* 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 = 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

---- Method 3

From
John Petersen
IDT Marketing Systems and
Services, Inc.
10/13/1998 10:43:37

Hi,

The RTF Control supports a SelPrint() method. To use it, you need to send an hDC
parameter. The hDC is a handle to a printer device context. Visual Basic handles this
automatically. We can do this same thing in VFP, but we need to use the services of the
Common Dialog Control. Ted Roche, Christof Lange, and I collaborated on a programmatic
way to do this without the Common Dialog - but it never has worked as cleanly as the
Common Dialog Solution.

To illustrate how to do the following:

1. Add an RTF Control to the form - name it RTF
2. Add a Common Dialog Control to the form - name it CommonDialog
3. Add a VFP CommandButton to the Form.

In the Init() of the CommonDialog, add this code:

This.Flags = 0x100

In the Click() of the CommandButton, add this code:

This.Parent.CommonDialog.ShowPrinter
This.Parent.rtf.SelPrint(This.Parent.CommonDialog.hdc)


Type some text into the RTF control and click the button.
>>Search the UT messages, there have been several threads on a couple of different ways of printing the RTF contents.
>>
>>>Is it possible to print RTF contained in a memo field from the report writer?
>
>I have searched, exhaustively, and have posted other messages myself on this topic, but still am in a quandry on how to print a memo field containing rich text with the report writer. I am tring to avoid using a third party tool or word processor merge, but I still need to have formatted characters for some letter content that my users are printing. Will I have to resort to WP merge or third party report writer, or can this be done inside VFP?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform