Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combining text from two RICH text textboxes
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00389346
Message ID:
00415117
Vues:
24
>I use the code below a method called Printit, I can't remember wherw I got it but it works. oleRTF being the control and oleTextRTF being one of it's properties. oleRTF is bound to a form property called Thisform.cText which is waht I use with StrToFile() for saving etc.
>Cheers
>John
>

THis can be simplified a lot by using CLSHEAP

>toRTF="Thisform.oleRTF"
>tcDoc="Thisform.oleRTF.textRTF"
>*-----------------------------------------------
>* 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 )
>Thisform.oleRTF.SelPrint( lnHDC )
>EndPage( lnHDC )
>EndDoc( lnHDC )
>DeleteDC( lnHDC )
>HeapFree(lnHeap, 0, lnDoc)
>HeapDestroy(lnHeap)
>Endif
SET CLASSLIB TO CLSHEAP ADDITIVE
oHeap = CREATEOBJ('Heap')
toRTF="Thisform.oleRTF"
tcDoc="Thisform.oleRTF.textRTF"
*-----------------------------------------------
* 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

*-----------------------------------------------
* 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)
   lnDoc = HeapAllocString(tcDoc)
   =StartDoc( lnHDC, DWORDToNum(12)+DWORDToNum(lnDoc)+DWORDToNum(0) )
   =StartPage( lnHDC )
   Thisform.oleRTF.SelPrint( lnHDC )
   =EndPage( lnHDC )
   =EndDoc( lnHDC )
   =DeleteDC( lnHDC )
   oHeap = NULL
Endif
The RTF control has a couple of properties that might be useful; the TextRTF property contains the control's content, RTF embedded codes and all, SelRTF contains the currently-selected RTF text. You can examine the RTF control in detail through the component gallery.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform