Bonjour,
J'ai reussi a faire un bouton pour imprimé ma form facture mais lorque je fais une impression ou si je fais un apercu avec impression, c'est une page blanche à la place de ce que contient ma form.
Quelqu'un aurait il une idée ??
Merci
Bonjour,
J'ai reussi a faire un bouton pour imprimé ma form facture mais lorque je fais une impression ou si je fais un apercu avec impression, c'est une page blanche à la place de ce que contient ma form.
Quelqu'un aurait il une idée ??
Merci
Montre nous le code que tu utilises (tu passes bien par un PrintDocument et autre: )
Thomas LEBRUN: MCAD.NET, MCTS (Win et Web), MCPD(Win et Web) & Microsoft MVP Client Application Development
WPF par la pratique, mon livre sur WPF ! (également disponible ici ou là)
A la découverte de .NET
oui enfin je donne mon code ce sera plus parlant
j'ai mis sa pour pouvoir choisir l'imprimante que l'on veut utilisé pour imprimer
Et cette partie aussi
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 private void btn_imprimer_Click(object sender, EventArgs e) { PrintDialog printDialog1 = new PrintDialog(); printDialog1.Document = printDocument1; DialogResult result = printDialog1.ShowDialog(); if (result == DialogResult.OK) { printDocument1.Print(); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawString("Facture",new Font("Arial",80,FontStyle.Regular),Brushes.Black, 808, 728); }
Envoyé par neguib
Desolé neguib mais je ne comprends pas comment ce topic pourrait m'aider, j'ai bien sur essaillé de comprendre avant de te repondre.
Mais pourrais tu juste me dire ce qui cloche dans mon code pour me mettre sur la voie, j'ai peut etre mal compris quelque chose sur la page que tu m'a donné.
J'ai cherché sur le forum avant de posté mon probleme et je n'est rien trouvé de concluant, j'ai même essaillé de convertir le code suivant parce qu'apparement faut faire une capture d'image de la form pour pouvoir ensuite l'imprimé, seulement sa me dit qu'il y a une erreur et vu que j'ai jamais fais de VB
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
24
25
26
27
28
29 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
Et je suis censé deviné laquelleEnvoyé par ShinS16
:
![]()
Convertisseur VBNet>CSharp
Voila ce que sa me dit :
Erreur lors de l'analyse du texte/fichier
-- line 1 col 9: invalid NonModuleDeclaration
La traduction en C# du code que tu as donné dans le convertisseur dont je t'ai donné le lien![]()
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
24
25
26
27
28
29
30
31 public class truc { [System.Runtime.InteropServices.DllImport("gdi32.dll", EntryPoint="BitBlt")] private static extern long BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, System.Int32 dwRop); Bitmap memoryImage; private void CaptureScreen() { Graphics mygraphics = this.CreateGraphics(); Size s = this.Size; memoryImage = new Bitmap(s.Width, s.Height, mygraphics); Graphics memoryGraphics = Graphics.FromImage(memoryImage); IntPtr dc1 = mygraphics.GetHdc; IntPtr dc2 = memoryGraphics.GetHdc; BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 0, 0, 13369376); mygraphics.ReleaseHdc(dc1); memoryGraphics.ReleaseHdc(dc2); } private void PrintDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawImage(memoryImage, 0, 0); } private void PrintButton_Click(object sender, System.EventArgs e) { CaptureScreen(); PrintDocument1.Print(); } }
Partager