Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help needed with RichText editor
Message
De
22/09/1999 04:00:29
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
21/09/1999 15:36:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00267300
Message ID:
00267470
Vues:
16
>I would like to be able (when a button is activated) to print from Microsoft Word the content of a field (RichText editor) in a form.
>
>I really don't need anything fancy.
>
>I just want to be able to:
>
>1) Open Word
>2) Print what I want
>3) Close Word
>4) Return to my application


Denis,
You could do it via word but could be problematic if you don't include a wait state and the word should check and/or wait for a network printer. Since you don't want anything fancy you could directly print from OleRTF. Below is the code for both. RTF printing code belongs to Christof Lange, I just made a small addition to make it compatible with VFP5+RichEdit V6 :
*Print commandbutton click
* via word
*lparameters toRTF, tcSaveFileName && Fullpath
**-cb-**	tcSaveFileName="c:\temp\test.rtf"
**-cb-**	toRTF.Object.SaveFile(tcSaveFileName,0)
**-cb-**	oWord = createobject("word.application")
**-cb-**	with oWord
**-cb-**		.Documents.Open(tcSaveFileName)
**-cb-**		.ActiveDocument.PrintOut
**-cb-**		.Applicaton.Quit()
**-cb-**	endwith
* via word

* via RTF Selprint

=richtextprint(toRTF,set("printer",2))

*RichTextPrint.prg
*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
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform