Bonjour à tous,

Voilà j'ai ce code récupéré sur Programmez qui permet de
faire des captures d'écran :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
private static Bitmap CaptureScreen(Rectangle rect)
        {
            Bitmap bitmap = new Bitmap(rect.Width, rect.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
            using (Graphics g = Graphics.FromImage(bitmap))
            {
                g.CopyFromScreen(rect.Left, rect.Top, 0,0, rect.Size, CopyPixelOperation.SourceCopy);
            }
 
            return bitmap;
        }
Hors je n'arrive pas à l'exploiter...

J'ai fait ça :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
private void button1_Click(object sender, EventArgs e)
        {
            CaptureScreen(Screen.PrimaryScreen.Bounds);
        }
Dans ma Form, mais sans succès

Comment faire pour me servir de ce code ?

Merci.