PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Tip: Screenshot einer Kylix Form machen



againsttcpa
06-04-2003, 17:24
Auto: Thierry Coq <thierry.coq@centraliens.net> (thierry.coq@centraliens-net)
Homepage: http://wwwusers.imageinet.fr/~tcoq

{
Capturing a CLX form is easy, once you know
It took me a little time to find out, so I'am giving the knowledge to help others:
}



type
TFormCaptureable=class(TForm)
public
procedure PrintOne;
end;

var
FormCaptureable: TFormCaptureable;


Implementation


uses QT;

procedure TFormCaptureable.PrintOne;
var
aBitmap: TBitmap;
aWinHandle: QWidgetH;
aWinId: Cardinal;
x, y, w, h: integer;
begin
//create a new bitmap to hold the captured screen
aBitmap := TBitmap.Create;
try
//get a handle on the desktop
aWinHandle := QApplication_desktop;
//get the Id from the desktop handle
aWinId := QWidget_winId(aWinHandle);
//get the position and size of the windows
x := Self.Top;
y := Self.Top;
w := Self.width;
h := Self.Height;
//capture the window into the bitmap's pixmap
QPixmap_grabWindows(aBitmap.Handle, aWinId, x, y, w, h);
//save the bitmap
aBitmap.SaveToFile('/path/myfile.bmp');
finally
//don't forget to kill the bitmap after use
FreeAndNil(aBitmap);
end
end;