Configurar impresion

17/10/2005 - 19:48 por Marauder | Informe spam
Private Declare Function BitBlt Lib "gdi32.dll" Alias "BitBlt" (ByVal _
hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As _
Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal _
hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, _
ByVal dwRop As System.Int32) As Long
Dim memoryImage As Bitmap
Private Sub CaptureScreen()
Dim mygraphics As Graphics = Me.CreateGraphics()
Dim s As Size = Me.Size
memoryImage = New Bitmap(s.Width, s.Height, mygraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
Dim dc1 As IntPtr = mygraphics.GetHdc
Dim dc2 As IntPtr = memoryGraphics.GetHdc
BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, _
Me.ClientRectangle.Height, dc1, 0, 0, 13369376)
mygraphics.ReleaseHdc(dc1)
memoryGraphics.ReleaseHdc(dc2)
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles _
PrintDocument1.PrintPage
e.Graphics.DrawImage(memoryImage, 0, 0)
End Sub
Private Sub PrintButton_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles PrintButton.Click
CaptureScreen()
PrintDocument1.Print()
End Sub
 

Leer las respuestas

#1 Marauder
17/10/2005 - 19:54 | Informe spam
Perdon,lo que he escrito no era lo que debia ser.Aqui esta mi pregunta.

Estoy intentado imprimir una grilla con el codigo que viene a continuacion
insertado en un boton, y a mi me interesa que salga la impresion apaisada
pero no lo consigo.¿Alguien me podria decir que he hecho mal en el código?.

Muchas gracias de antemano.

PrintDocument1.PrinterSettings.DefaultPageSettings.Landscape = True

PrintDialog1.Document = PrintDocument1

If PrintDialog1.ShowDialog = DialogResult.OK Then
Grilla1.PrintGrid("IMPRESION")
End If

Preguntas similares