2004. március 8., hétfő
How to get the bitmap on a hidden TWinControl
Problem/Question/Abstract:
I want to get a bitmap from the Device Context of a TWinControl that is hidden. Is this possible? I know the handle, but GetDC, Canvas.copyrect etc. return the desktop image.
Answer:
procedure TForm1.Button2Click(Sender: TObject);
var
FControlCanvas: TControlCanvas;
FBitmap: TBitmap;
begin
FControlCanvas := TControlCanvas.Create;
try
FControlCanvas.Control := StringGrid1;
FBitmap := TBitmap.Create;
try
FBitmap.Width := FControlCanvas.Control.Width;
FBitmap.Height := FControlCanvas.Control.Height;
FBitmap.Canvas.CopyRect(Rect(0, 0, FBitmap.Width, FBitmap.Height), FControlCanvas,
Rect(0, 0, FBitmap.Width, FBitmap.Height));
Image1.Picture.Assign(FBitmap);
finally
FBitmap.Free;
end;
finally
FControlCanvas.Free;
end;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése