2009. november 2., hétfő
How to capture the Windows desktop to a form canvas
Problem/Question/Abstract:
How to capture the Windows desktop to a form canvas
Answer:
procedure TScrnFrm.GrabScreen;
var
DeskTopDC: HDc;
DeskTopCanvas: TCanvas;
DeskTopRect: TRect;
begin
DeskTopDC := GetWindowDC(GetDeskTopWindow);
DeskTopCanvas := TCanvas.Create;
DeskTopCanvas.Handle := DeskTopDC;
DeskTopRect := Rect(0, 0, Screen.Width, Screen.Height);
ScrnForm.Canvas.CopyRect(DeskTopRect, DeskTopCanvas, DeskTopRect);
ReleaseDC(GetDeskTopWindow, DeskTopDC);
end;
Note: You may also have to play around with coordinates, depending on what you want to do. Also, if your form is already loaded and displayed, that is what you you will get, so you may want to do a hide and a show.
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése