alexandreillusion
Messages postés37Date d'inscriptionlundi 7 juillet 2008StatutMembreDernière intervention14 mars 2011
-
11 nov. 2008 à 13:57
gillardg
Messages postés3275Date d'inscriptionjeudi 3 avril 2008StatutMembreDernière intervention14 septembre 2014
-
11 nov. 2008 à 15:09
je cherche à imprimer une form en paysage ce que j'arrive a faire. en revanche je ne reussi pas centrer sur la page cette form. pourriez vous m'aider ?
merci pour le temps que vous me consacrerez.
voici la partis du code qui imprime:
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 = demande_dappro.CreateGraphics()
Dim s As Size = demande_dappro.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, demande_dappro.ClientRectangle.Width, _
demande_dappro.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 Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
CaptureScreen()
Dim psDlg As New PageSetupDialog
Dim LePageSettings As New Printing.PageSettings
psDlg.PageSettings = LePageSettings
psDlg.PageSettings.Landscape = True
psDlg.PageSettings.Margins.Left = 30 'les marges qui fonctionnent pas mais pourquoi?
psDlg.PageSettings = LePageSettings
Dim dllg As New PrintPreviewDialog
dllg.Document = PrintDocument1
dllg.ShowDialog()
If MsgBox("etes-vous sur de vouloir imprimer ce bon?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "impression?") = MsgBoxResult.No Then
GoTo fin
Else