Printing Scintilla editor text - very easy...

Share your advanced PureBasic knowledge/code with the community.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Printing Scintilla editor text - very easy...

Post by DoubleDutch »

This code will enable you to do a colour printout from a Scintilla editor window:

Code: Select all

length=SCI_GetLength()
If length
  FormatRange.FORMATRANGE 
  If PrintRequester()
    width=PrinterPageWidth()
    height=PrinterPageHeight()
    FormatRange\rc\left=0 
    FormatRange\rc\top=0
    FormatRange\rc\right=width
    FormatRange\rc\bottom=height
    FormatRange\rcPage\left=0 
    FormatRange\rcPage\top=0 
    FormatRange\rcPage\right=width
    FormatRange\rcPage\bottom=height
    FormatRange\chrg\cpMin=0
    FormatRange\chrg\cpMax=length
    If StartPrinting("ReportBuilder Draft")
      dc=StartDrawing(PrinterOutput())
      If dc
        FormatRange\hDC=dc
        FormatRange\hdcTarget=dc
        FormatRange\chrg\cpMin=SCI_FormatRange(#True,FormatRange)
        While FormatRange\chrg\cpMin<FormatRange\chrg\cpMax 
          NewPrinterPage()
          FormatRange\chrg\cpMin=SCI_FormatRange(#True,FormatRange)
        Wend
        StopDrawing()
      EndIf
      StopPrinting()
    EndIf
  EndIf
EndIf
Use the SCI_SetPrintColourMode(x) calls to set the various colour modes beforehand.

Find the Scintilla includes in the usual places...
(If you don't already have them then this code will be of no use to you! ;) )
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system