Bonjour,
Je voudrais faire une copie d'écran d'un Panel de ma Form afin de sauvegarder sous forme Bmp.
J'ai vu cette discussion qui fonctionne sous Delphi :
https://www.developpez.net/forums/d6...ecran-d-panel/
J'ai utilisé la solution de dd16 mais j'obtiens une image noire.
Dont voici le code très légèrement modifié :
Après plusieurs essais notamment d'utiliser ".Canvas.Changed" trouver dans certaine discussion rien ni fait. Je comprends pas.
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 procedure TForm1.Button3Click(Sender: TObject); var bmp:Graphics.Tbitmap; HDC_Panel:HDC; area:Trect; Canvas_tmp:TCanvas; begin HDC_panel:=GetWindowDC(panel1.handle); bmp:=Graphics.TBitmap.Create; Canvas_tmp:=TCanvas.create; Canvas_tmp.Handle:=HDC_Panel; bmp.width:=panel1.width; // dimension du bitmap = dimension du panel bmp.height:=panel1.height; area.Bottom:=0; area.Top:=0; area.Width:=panel1.width; area.Height:=panel1.height; // copy du fond windows bmp.canvas.copyrect(area,Canvas_tmp,area); ReleaseDC(Canvas_tmp.handle,HDC_Panel); // le bitmap bmp contient le resultat // ici, je le copie sur un Timage de la meme taille pour verifier que ca marche image1.picture.assign(bmp); bmp.free; Canvas_tmp.free; end;
Merci pour votre aide.
Windows 10 64 bit
Lazarus version 1.8.2 64bit
Partager