Bonjour,
J'ai un souci au niveau de l'impression d'une capture écran, en fait je souhaite capturer toute la form qui est ouverte donc il me faudrait redimensionner ma form pour qu'elle rentre sur ma feuille mais je ne sais pas comment faire pouvez-vous m'aider please ??
je vous mais le code de l'apercu avant impression:
Ainsi que celui de la capture ecran :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 Private Sub Apercu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click Dim dllg As New PrintPreviewDialog CaptureScreen() dllg.Width = 1275 dllg.Height = 850 dllg.Document = PrintDocument1 dllg.ShowDialog() End Sub
et celui pour imprimer :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 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
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 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 Imprimer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click Dim dlg As New PrintDialog CaptureScreen() dlg.Document = PrintDocument1 Dim result As DialogResult = dlg.ShowDialog() If (result = System.Windows.Forms.DialogResult.OK) Then PrintDocument1.Print() End If End Sub
Partager