Bonjour à tous, j'ai un petit problème
je suis en train de me créer un System.Drawing.Printing.PrintDocument qui gère parfaitement les sauts de page. Bon le concepte est déjà créé, mais j'ai un petit problème lors de l'impression.
je dois ajouter un object de type System.Drawing.Graphics dans un 2e System.Drawing.Graphics
genre: e.Graphics.DrawGraphics(myGraphics,0,0)
domage, mais DrawGraphics n'existe pas
d'après ce que j'ai lu sur internet, je dois convertir myGraphics en type bitmap et après utiliser drawImage, mais je reçoi toujours un bitmap vide ou un bitmap noir complètement.
Voici ma fonction que je me sert pour convertir un graphics en type Bitmap
Private Declare Function BitBlt Lib "gdi32.dll" (ByVal hDestDC As IntPtr, ByVal x As Int32, ByVal y As Int32, ByVal nWidth As Int32, ByVal nHeight As Int32, ByVal hSrcDC As IntPtr, ByVal xSrc As Int32, ByVal ySrc As Int32, ByVal dwRop As Int32) As Int32
Private Const SRCCOPY As Int32 = &HCC0020
Public Function GetPictureOfGraphics(ByVal Width As Integer, ByVal Height As Integer, ByRef srcPic As Graphics) As Bitmap
Dim srcBmp As New Bitmap(Width, Height, srcPic)
Dim copyRect As Bitmap
'Create a Graphics object in memory from that bitmap
Dim srcMem As Graphics = Graphics.FromImage(srcBmp)
'get the IntPtr's of the graphics
Dim HDC1 As IntPtr = srcPic.GetHdc
'get the IntPtr's of the graphics
Dim HDC2 As IntPtr = srcMem.GetHdc
'get the picture
BitBlt(HDC2, 0, 0, Width, Height, HDC1, 0, 0, SRCCOPY)
'Clean Up
copyRect = srcBmp.Clone()
srcPic.ReleaseHdc(HDC1)
srcMem.ReleaseHdc(HDC2)
srcPic.Dispose()
srcMem.Dispose()
Return copyRect
End Function
et voici mon code qui call cette fonction
Private Sub PrintDocumentSofticket_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles Me.PrintPage
Dim font As New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
For i As Integer = 1 To 20
e.Graphics.DrawString("Paneau " & i, font, Brushes.Black, 0, 0)
e.Graphics.DrawImage(Image.FromFile("C:\programmation2\Programmation\Softicket Develop\Build\Images\Softicket_Grand_Logo copie1.bmp"), 5, 16)
Next i
GetPictureOfGraphics(Me.PrinterSettings.DefaultPageSettings.PaperSize.Width, Me.PrinterSettings.DefaultPageSettings.PaperSize.Height, e.Graphics).Save("C:/testprint.png")
End Sub
Ceci est seulement un test simple et qui ne fonctionne pas. Le fichier C:/testprint.png est toujours vide ou noir, comme mentionné plus haut
Quelqu'un peut m'aider SVP
-------------------------------------------------
Dragon alias aussi Waxime mais bon, pas le gout de refaire un nouveau profil lol
-------------------------------------------------