Berikut ini adalah contoh aplikasi untuk mengcapture screen dan menyimpannya.
procedure TForm1.Button1Click(Sender: TObject); var DCDesk: HDC; Bmp: TBitmap; begin Bmp:= TBitmap.Create; Bmp.Height:= Screen.Height; Bmp.Width:= Screen.Width; DCDesk:= GetWindowDC(GetDesktopWindow); BitBlt(Bmp.Canvas.Handle, 0, 0, Screen.Width, Screen.Height, DCDesk, 0, 0, SRCCOPY); SavePictureDialog1.Title:= ''; if SavePictureDialog1.Execute then begin SavePictureDialog1.InitialDir:= ExtractFilePath( Application.ExeName); Bmp.SaveToFile(SavePictureDialog1.FileName); end; ReleaseDC(GetDesktopWindow, DCDesk); Bmp.Free; end; procedure TForm1.FormCreate(Sender: TObject); begin SavePictureDialog1.FileName:= '*.bmp'; end;
Comments
Post a Comment