Salut,
On peut également créer deux procédures utilisables pour capturer tous les TWinControl (y compris le TPageControl avec ses listes déroulantes...)
vers un fichier bitmap :
procedure ControlToBitmapFile(AControl: TWinControl; FileName: string);
var
DC: HDC;
begin
if not Assigned(AControl) then Exit;
DC := GetWindowDC(AControl.Handle);
try
with TBitmap.Create do
try
Width := AControl.Width;
Height := AControl.Height;
BitBlt(Canvas.Handle, 0, 0, Width, Height, DC, 0, 0, SrcCopy);
SaveToFile(FileName);
finally
Free;
end;
finally
ReleaseDC(AControl.Handle, DC);
end;
end;
vers un TBitmap :
procedure ControlToBitmap(AControl: TWinControl; Bmp: TBitmap);
var
DC: HDC;
begin
if not Assigned(AControl) or not Assigned(Bmp) then Exit;
DC := GetWindowDC(AControl.Handle);
try
with Bmp do
begin
Width := AControl.Width;
Height := AControl.Height;
BitBlt(Canvas.Handle, 0, 0, Width, Height, DC, 0, 0, SrcCopy);
end;
finally
ReleaseDC(AControl.Handle, DC);
end;
end;