Dobrý den! K tisku používam nasledujíci kod:
imports System.Windows.Forms
Imports System.Runtime.InteropServices
Public Class MDIParent1
Private Enum DrawingOptions
PRF_CHECKVISIBLE = &H1
PRF_NONCLIENT = &H2
PRF_CLIENT = &H4
PRF_ERASEBKGND = &H8
PRF_CHILDREN = &H10
PRF_OWNED = &H20
End Enum
Private Const WM_PRINT As Integer = &H317
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function SendMessage(ByVal handle As IntPtr, ByVal msg As Integer, ByVal wparam As IntPtr, ByVal lparam As Integer) As IntPtr
End Function
Private bmp As Bitmap
Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click
bmp = New Bitmap(Panel1.DisplayRectangle.Width, Panel1.DisplayRectangle.Height)
Dim g As Graphics = Graphics.FromImage(bmp)
Dim hdc As IntPtr = g.GetHdc()
SendMessage(Panel1.Handle, WM_PRINT, hdc, DrawingOptions.PRF_OWNED Or DrawingOptions.PRF_CHILDREN Or DrawingOptions.PRF_CLIENT Or DrawingOptions.PRF_NONCLIENT)
g.ReleaseHdc(hdc)
g.Dispose()
PrintPreviewDialog1.document = Printdocument1
PrintPreviewDialog1.showdialog()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.DrawImage(bmp, 0, 0)
End Sub
Problem je v kvalite tisku dat z formularu resp. panelu. Jak se da docílit zlešení kvality tisku obsahu prvku "panel" Dik Peter
|