Если верить MSDN, то в среде Windows XP SP1 у контрола Rich Edit версия 4.1 и библиотека Msftedit.dll
WordPad действительно с этим контролом, а в среде VB.NET почему-то "цепляется" вторая версия.
Кто сможет что-то пояснить, пожалуйста ???
Покажи код того, как ты это делаешь.с помощью EM_FORMATRANGE это делается. но в присутствии "предварительного просмотра", а без него, пока ничего не могу придумать
Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint
' Start at the beginning of the text
m_nFirstCharOnPage = 0
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
' To print the boundaries of the current page margins
m_nFirstCharOnPage = ed.FormatRange(False, _
e, _
m_nFirstCharOnPage, _
ed.TextLength)
' check if there are more pages to print
If (m_nFirstCharOnPage < ed.TextLength) Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
End Sub
Private Sub PrintDocument1_EndPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.EndPrint
' Clean up cached information
ed.FormatRangeDone()
End Sub
Public Function FormatRange(ByVal measureOnly As Boolean, _
ByVal e As PrintPageEventArgs, _
ByVal charFrom As Integer, _
ByVal charTo As Integer) As Integer
' диапазон между символами для печати
Dim cr As STRUCT_CHARRANGE
cr.cpMin = charFrom
cr.cpMax = charTo
' площадь внутри полей страницы
Dim rc As STRUCT_RECT
Dim rcPage As STRUCT_RECT
'Dim rc As STRUCT_RECT
rc.top = HundredthInchToTwips(e.MarginBounds.Top)
rc.bottom = HundredthInchToTwips(e.MarginBounds.Bottom)
rc.left = HundredthInchToTwips(e.MarginBounds.Left)
rc.right = HundredthInchToTwips(e.MarginBounds.Right)
' Specify the page area
'Dim rcPage As STRUCT_RECT
rcPage.top = HundredthInchToTwips(e.PageBounds.Top)
rcPage.bottom = HundredthInchToTwips(e.PageBounds.Bottom)
rcPage.left = HundredthInchToTwips(e.PageBounds.Left)
rcPage.right = HundredthInchToTwips(e.PageBounds.Right)
Dim hdc As IntPtr
' Get device context of output device
'Dim hdc As IntPtr
hdc = e.Graphics.GetHdc()
' Fill in the FORMATRANGE structure
Dim fr As STRUCT_FORMATRANGE
fr.chrg = cr
fr.hdc = hdc
fr.hdcTarget = hdc
fr.rc = rc
fr.rcPage = rcPage
' Non-Zero wParam means render, Zero means measure
Dim wParam As Int32
If measureOnly Then
wParam = 0
Else
wParam = 1
End If
' Allocate memory for the FORMATRANGE struct and
' copy the contents of our struct to this memory
Dim lParam As IntPtr
lParam = Marshal.AllocCoTaskMem(Marshal.SizeOf(fr))
Marshal.StructureToPtr(fr, lParam, False)
' Send the actual Win32 message
Dim res As Integer
res = SendMessage(Handle, EM_FORMATRANGE, wParam, lParam)
' Free allocated memory
Marshal.FreeCoTaskMem(lParam)
' and release the device context
e.Graphics.ReleaseHdc(hdc)
Return res
End Function
' Convert between 1/100 inch (unit used by the .NET framework)
' and twips (1/1440 inch, used by Win32 API calls)
'
' Parameter "n": Value in 1/100 inch
' Return value: Value in twips
Private Function HundredthInchToTwips(ByVal n As Integer) As Int32
Return Convert.ToInt32(n * 14.4)
End Function
' Free cached data from rich edit control after printing
Public Sub FormatRangeDone()
Dim lParam As New IntPtr(0)
SendMessage(Handle, EM_FORMATRANGE, 0, lParam)
End Sub
Ну и в чем затык то? Используй SendMessage(Handle, EM_FORMATRANGE, wParam, lParam)а без него, пока ничего не могу придумать
Сейчас этот форум просматривают: SemrushBot и гости: 86