{"id":133,"date":"2007-05-12T14:57:50","date_gmt":"2007-05-12T12:57:50","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/screen-capture\/"},"modified":"2007-05-12T14:57:52","modified_gmt":"2007-05-12T12:57:52","slug":"screen-capture","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/screen-capture\/","title":{"rendered":"Screen capture"},"content":{"rendered":"<p>How to capture the desktop screen<\/p>\n<p>[code lang=&#8221;delphi&#8221;]procedure TForm1.GetDesktopBitmap;<br \/>\n Var<br \/>\n  DeskHWnd : Hwnd;<br \/>\n  dc: HDC;<br \/>\n  ScreenWidth, ScreenHeight: Integer;<br \/>\n  TheBmp : TBitmap;<br \/>\n  FName : String;<br \/>\nbegin<br \/>\n  \/\/ Get the handle of the Desktop<br \/>\n DeskHWnd := GetDeskTopWindow;<br \/>\n\/\/ Get the DeviceContext<br \/>\n dc := GetDC(DeskHWnd);<br \/>\n\/\/ Get the screen dimensions<br \/>\n ScreenWidth := GetDeviceCaps(dc,HORZRES);<br \/>\n ScreenHeight := GetDeviceCaps(dc,VERTRES);<br \/>\n\/\/ Create the bitmap<br \/>\n   TheBmp := TBitmap.Create;<br \/>\n   TheBmp.Width := ScreenWidth;<br \/>\n   TheBmp.Height := ScreenHeight;<br \/>\n\/\/ Lets paint the desktop on the bitmap.<br \/>\n   BitBlt(TheBmp.Canvas.Handle, 0,0,ScreenWidth,ScreenHeight,dc, 0,0,SRCCOPY);<br \/>\n\/\/ Now we put the bitmap into a TImage<br \/>\n   Image1.Picture.Bitmap := TheBmp;<br \/>\n   Application.ProcessMessages;<br \/>\n   TheBmp.Free;<br \/>\n   ReleaseDC(DeskHWnd, dc);<br \/>\n\/\/ We need a filename to save it to.<br \/>\n   FName := ExtractFilePath(Application.Exename) + &#8216;capture.bmp&#8217;;<br \/>\n\/\/ Lets save the bitmap to a file.<br \/>\n   Image1.Picture.Bitmap.SaveToFile(FName);<br \/>\nend;<br \/>\n[\/code]<\/p>\n<p>[tags]Delphi, Graphic[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to capture the desktop screen [code lang=&#8221;delphi&#8221;]procedure TForm1.GetDesktopBitmap; Var DeskHWnd : Hwnd; dc: HDC; ScreenWidth, ScreenHeight: Integer; TheBmp : TBitmap; FName :&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[11],"tags":[75,101],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p71Tml-29","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/133"}],"collection":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/comments?post=133"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}