UNKNOWN '************************************** ' Name: Draw Pages Using DrawTextExW ' Description:DrawTextExW (or the Ansi v ' ersion DrawTextEx) returns the length dr ' awn so can be used to easily draw (and p ' rint) pages of plain text. ' By: Je. ' ' ' Inputs:None ' ' Returns:None ' 'Assumes:None ' 'Side Effects:None 'This code is copyrighted and has limite ' d warranties. 'Please see http://www.Planet-Source-Cod ' e.com/xq/ASP/txtCodeId.74587/lngWId.1/qx ' /vb/scripts/ShowCode.htm 'for details. '************************************** 'in a form 'PUT SOME TEXT ON THE CLIPBOARD THEN RUN ' Private Type DRAWTEXTPARAMS cbSize As Long iTabLength As Long iLeftMargin As Long iRightMargin As Long uiLengthDrawn As Long End Type Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Const DT_WORDBREAK = &H10, DT_EDITCONTROL = &H2000 Private Declare Function DrawTextExW Lib "user32" (ByVal hDC As Long, ByVal lpsz As Any, ByVal n As Long, lpRect As RECT, ByVal dwDTFormat As Long, lpDrawTextParams As Any) As Long Private Declare Function setrect Lib "user32" Alias "SetRect" (lpRect As RECT, ByVal x1 As Long, ByVal y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Private Declare Function OffsetRect Lib "user32" (lpRect As RECT, ByVal X As Long, ByVal Y As Long) As Long Private Sub Form_Load() Dim dtt As DRAWTEXTPARAMS, r As RECT, st As String, n As Long, res As Long With Me .ScaleMode = vbPixels .AutoRedraw = True .ForeColor = vbBlack End With dtt.cbSize = Len(dtt) setrect r, 10, 10, 300, 200 st = Clipboard.GetText Do Until n >= Len(st) 'Loop till all pages drawn With r 'DRAWBORDER Me.Line (.Left, .Top)-(.Right, .Bottom), vbWhite, BF Me.Line (.Left, .Top)-(.Right, .Bottom), vbBlack, B End With 'ONE LINE PRINTS PAGE res = DrawTextExW(Me.hDC, ByVal CLng(StrPtr(st) + (n * 2)), Len(st) - n, r, DT_WORDBREAK Or DT_EDITCONTROL, ByVal VarPtr(dtt)) n = n + dtt.uiLengthDrawn OffsetRect r, 50, 50 Loop Me.Refresh End Sub