Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Printing with RichText control
Message
De
27/08/2001 16:32:58
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
00549439
Message ID:
00549613
Vues:
15
>>I've got some richtext generated by the RichText control and am trying to print that richtext in a Report Writer report. I used the steps outlined in KB Q246088 as a starting point, but every time I print I get a Notepad icon instead of the RichText. Furthermore, I am not confident that the Picture/Active-X Bound Control in the report will stretch to accomodate the content. It's currently clipping the Notepad icon and I don't see a "Stretch with Overflow" type option such as the one available for TextBox fields (the other options are Scale picture and don't indicate that the frame changes size).
>>
>>Printing using the richtext controls SelPrint method works fine, but I really need printing within a report as well.
>>
>>I dump the data to a file (the DATA clause was giving me an error) and then stick it into the general field sol_strategy which is used by the report:
>>APPEND GENERAL sol_strategy FROM rtftest.txt CLASS "RICHTEXT.RICHTEXTCTRL.1"
>>
>>Configuration problem? Programming problem that can be corrected? Known problem with RichText control? Third-party control available?
>>
>>Thanks,
>>Sean Hurley
>
>Sean,
>
>Here is the code behind a 'print' button:
>
>LOCAL lcPrinter, oPrinter
>lcPrinter = GETPRINTER()
>lcTitle = "RTF Printout"
>SET PROCEDURE TO PrtClass.PRG ADDITIVE
>oPrinter = CREATEOBJECT("PrintObj",lcPrinter)
>WITH oPrinter
>	.StartDoc(.hDC, lcTitle)
>	.StartPage(.hDC)
>	This.Parent.Rtfcontrol1.Olecontrol1.SelPrint(.hDC)
>	.EndPage(.hDC)
>	.EndDoc(.hDC)
>ENDWITH
>RELEASE oPrinter
>RELEASE PROCEDURE PrtClass
>
>
>Here is prtclass.prg, which contains the class definition:
>
>
>DEFINE CLASS PrintObj AS LINE
>	hDC = 0 && holds the printer device context
>	PROTECTED lnHeap, lnDoc
>	lnHeap = 0
>	lnDoc = 0
>	PROCEDURE INIT(tcPrinter) && optionally, specify printer
>		*Set up the Win API calls we'll need
>		THIS.DeclareDLLs()
>		* Create the Device Context
>		THIS.hDC = THIS.CreateDC(tcPrinter)
>	ENDPROC
>
>	PROCEDURE DESTROY
>		DeleteDC(THIS.hDC)
>	ENDPROC
>
>	PROCEDURE CreateDC(tcPrinter)
>		* If no printer is specified, use the * first from APRINTERS()
>		IF TYPE("tcPrinter")<>"C" OR EMPTY(tcPrinter)
>			LOCAL laPrint[1,2], lncount
>			lncount = APRINTERS(laPrint)
>			IF lncount > 0
>				tcPrintar = laPrint[1,1]
>			ELSE
>				tcPrinter = ""
>			ENDIF
>		ENDIF
>		RETURN CreateDC("WINSPOOL",tcPrinter,0,0)
>
>	PROCEDURE DeclareDLLs( )
>	  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 Istrcpy IN Win32Api INTEGER, STRING
>	ENDPROC
>
>	PROCEDURE StartDoc(tnhDC, toDocName)
>		* Run the Win API StartDoc function
>		tcDocName = IIF(TYPE("tcDocName")<> "C","", tcDocName)
>
>		LOCAL lnHeap, lnDoc, lcStruct
>		* Create a Windows string w/ pointer for the queue name
>		THIS.lnHeap = HeapCreate(0, 8192, 8192)
>		THIS.lnDoc = HeapAlloc(THIS.lnHeap, 0, LEN(tcDocName)+1 )
>		Istrcpy ( THIS. lnDoc, tcDocName )
>		* Create a structure
>		lcStruct = THIS.Toint(12) + ;
>			THIS.Toint( ;
>			IIF(EMPTY(tcDocName), 0, THIS.lnDoc)) + ;
>			THIS.Toint(0)
>		* Call the win API function
>		StartDoc(tnhDC, lcStruct)
>	ENDPROC
>
>	FUNCTION Toint(tiNumber)  && convert number to Intel
>		* four byte string in low-byte, high-byte format
>		LOCAL cString, nT
>		cString = ''
>		FOR nT = 1 TO 4
>			cString = cString + CHR(tiNumber%256)
>			tiNumber = INT(tiNumber /256)
>		ENDFOR
>		RETURN cString
>
>	PROCEDURE EndDoc(tnhDC)
>		* Release the Heap, if allocated
>		IF THIS.lnHeap <> 0 OR THIS.lnDoc <> 0
>			* Free the memory allocated above
>			HeapFree(THIS.lnBeap, 0, THIS.lnDoc)
>			HeapDestroy(THIS.lnHeap)
>		ENDIF
>		RETURN EndDoc(tnhDC)
>
>	PROCEDURE StartPage(tnhDC)
>		RETURN StartPage(tnhDC)
>
>	PROCEDURE EndPage(tnhDC)
>		RETURN EndPage(tnhDC)
>
>ENDDEFINE
>
>
>
>Works find on WinXX but doesn't appear to work on W2K, yet.
>JLK


.SelPrint works fine for me. It's printing from the report writer that is the problem.

Sean
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform