
12.05.2011, 18:37
|
 |
Активный
|
|
Регистрация: 22.01.2010
Сообщения: 211
Версия Delphi: 7, 2010
Репутация: 1349
|
|
Код:
function GetScreenShot: TBitmap;
var
DC: HDC;
begin
Result := TBitmap.Create;
with Result do
begin
Width := Screen.Width;
Height := Screen.Height;
DC := GetDC(0);
try
BitBlt(Canvas.Handle, 0, 0, Width, Height, DC, 0, 0, SRCCOPY);
finally
ReleaseDC(0, DC);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Path: string;
BMP: TBitmap;
begin
Path := ExtractFilePath(Application.ExeName) + Edit1.Text;
CreateDir(Path); // создаём папку
BMP := GetScreenShot; // делаем скриншот (см. функцию выше)
BMP.SaveToFile(Path + '\screenshot.bmp'); // сохраняем в файл
BMP.Free;
end;
|