> Does anyone know how to get a bitmap of the current screen contents
> within a Delphi Program..
var
bm : TBitMap;
begin
bm := TBitMap.Create;
bm := MainForm.GetFormImage;
// do here whatever you want
bm.Free;
end;
Hope it helps
Robert
************************************************************************************
Hi Steven,
> Does anyone know how to get a bitmap of the current screen contents
> within a Delphi Program.
You can copy the current screen to the clipboard (or assign it to a
bitmap component). The former can be implemented as follows:
procedure ScreenShot;
var
ScreenDC: HDC;
ScreenHandle: HWnd;
ScreenBitmap: TBitmap;
begin
ScreenHandle := GetDeskTopWindow;
ScreenDC := GetDC(ScreenHandle);
try
ScreenBitmap := TBitMap.Create;
try
ScreenBitmap.Width := Screen.Width;
ScreenBitmap.Height := Screen.Height;
BitBlt(ScreenBitmap.Canvas.Handle, 0, 0,
Screen.Width, Screen.Height, ScreenDC, 0, 0, SRCCOPY);
Clipboard.Assign(ScreenBitmap)
finally
ScreenBitmap.Free
end
finally
ReleaseDC(ScreenHandle, ScreenDC)
end
end {ScreenShot};
An complete article about this solution can be seen on my website at
http://www.drbob42.com/uk-bug/hood-10.htm
> Steven Coombs
Groetjes,
Bob Swart (aka Dr.Bob - www.drbob42.com)
--
drs. Robert E. (Bob) Swart, @-Consultant, Delphi Trainer & Author
Delphi OplossingsCentrum (DOC) & UK-BUG Borland User Group member