title image


Smiley Re: Wer hat einen Druckquellcode für einen Anfänger ? Es geht um die RTFBox
Hai Racker,schau mal ob dir das hilft( etwas tiefer im Forum gefunden )TschauUwe...---------- SCHNIPP ------Servus,hier hast Du ein Modulstatt Form1.picture mußt Du durch Printer ersetzen wenn Du denn RTF Text mit dem Drucker ausgeben willst.Bei Form1.Picture wird der Text in einer PictureBox auf dem Bildschirm in Form1 ausgegeben.GrußBockingeraufruf:MRtfPrint.PrintRTF RTF:=txtmain, LeftMarginWidth:=200, _TopMarginHeight:=500, _RightMarginWidth:=100, _BottomMarginHeight:=100 ' 1440 Twips = 1 Inch'Leftmarginwidth=linker rand wo eingerückt wird'righrmarginwidth=rechter Rand wo eingerückt wird'topmarginheigt: Gibt an ab wo angefangen wird den Text zu drucken (Höhe)Modul:Option ExplicitPrivate Type RectLeft As LongTop As LongRight As LongBottom As LongEnd TypePrivate Type CharRangecpMin As Long ' First character of range (0 for start of doc)cpMax As Long ' Last character of range (-1 for end of doc)End TypePrivate Type FormatRangehdc As Long ' Actual DC to draw onhdcTarget As Long ' Target DC for determining text formattingrc As Rect ' Region of the DC to draw to (in twips)rcPage As Rect ' Region of the entire DC (page size) (in twips)chrg As CharRange ' Range of text to draw (see above declaration)End TypePrivate Const WM_USER As Long = &H400Private Const EM_FORMATRANGE As Long = WM_USER + 57Private Const EM_SETTARGETDEVICE As Long = WM_USER + 72Private Const PHYSICALOFFSETX As Long = 112Private Const PHYSICALOFFSETY As Long = 113Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As LongPrivate Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal msg As Long, ByVal wp As Long, lp As Any) As LongPrivate Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As Long, ByVal lpInitData As Long) As Long' PrintRTF - Prints the contents of a RichTextBox control using the' provided margins '' RTF - A RichTextBox control to print' LeftMarginWidth - Width of desired left margin in twips '' TopMarginHeight - Height of desired top margin in twips '' RightMarginWidth - Width of desired right margin in twips '' BottomMarginHeight - Height of desired bottom margin in twips '' Notes - If you are also using WYSIWYG_RTF() on the provided RTF' parameter you should specify the same LeftMarginWidth and' RightMarginWidth that you used to call WYSIWYG_RTF()Public Sub PrintRTF(RTF As RichTextBox, LeftMarginWidth As Long, TopMarginHeight, RightMarginWidth, BottomMarginHeight)Dim LeftOffset As Long, TopOffset As LongDim LeftMargin As Long, TopMargin As LongDim RightMargin As Long, BottomMargin As LongDim fr As FormatRangeDim rcDrawTo As RectDim rcPage As RectDim TextLength As LongDim NextCharPosition As LongDim r As Long' Start a print job to get a valid form1.picture1.hDC'form1.picture1.Print Space(1)'form1.picture1.ScaleMode = vbTwips' Get the offsett to the printable area on the page in twips' Calculate the Left, Top, Right, and Bottom marginsLeftMargin = LeftMarginWidth - LeftOffsetTopMargin = TopMarginHeight - TopOffsetRightMargin = (Form1.Picture1.Width - RightMarginWidth) - LeftOffsetBottomMargin = (Form1.Picture1.Height - BottomMarginHeight) - TopOffset' Set printable area rectrcPage.Left = 0rcPage.Top = 0rcPage.Right = Form1.Picture1.ScaleWidthrcPage.Bottom = Form1.Picture1.ScaleHeight' Set rect in which to print (relative to printable area)rcDrawTo.Left = LeftMarginrcDrawTo.Top = TopMarginrcDrawTo.Right = RightMarginrcDrawTo.Bottom = BottomMargin' Set up the print instructionsfr.hdc = Form1.Picture1.hdc ' Use the same DC for measuring and renderingfr.hdcTarget = Form1.Picture1.hdc ' Point at form1.picture1 hDCfr.rc = rcDrawTo ' Indicate the area on page to draw tofr.rcPage = rcPage ' Indicate entire size of pagefr.chrg.cpMin = 0 ' Indicate start of text throughfr.chrg.cpMax = -1 ' end of the textTextLength = Len(RTF.Text)Dim Anzahl As IntegerAnzahl = 0DoIf Anzahl > 0 ThenForm1.Picture1.ClsBeeprcDrawTo.Top = 100fr.rc = rcDrawTo ' Indicate the area on page to draw tofr.rcPage = rcPage ' Indicate entire size of pagefr.chrg.cpMax = -1NextCharPosition = SendMessage(RTF.hWnd, EM_FORMATRANGE, True, fr)If NextCharPosition >= TextLength Then Exit Dofr.chrg.cpMin = NextCharPosition'Form1.Picture1.Clsfr.hdc = Form1.Picture1.hdcfr.hdcTarget = Form1.Picture1.hdcElseNextCharPosition = SendMessage(RTF.hWnd, EM_FORMATRANGE, True, fr)If NextCharPosition >= TextLength Then Exit DoAnzahl = Anzahl + 1fr.chrg.cpMin = NextCharPosition'Form1.Picture1.Clsfr.hdc = Form1.Picture1.hdcfr.hdcTarget = Form1.Picture1.hdcEnd IfLoopr = SendMessage(RTF.hWnd, EM_FORMATRANGE, False, ByVal CLng(0))End SubGeschickt von Bockinger am 09. Mai 2000 um 17:23.10Bezogen auf Wer hat einen perfekten Druckquellcode für die rtfTextBox ? von Racker am 09. Mai 2000 um 16:17.13
[Bild]
Ach wie gerne würde ich die Welt verbessern, doch Gott gibt mir den Quellcode nicht.

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: