Screen Capturing Routines


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

This is a multi-purpose selection of screen capturing routines.

You can use it to capture a passed in VB Form or any window with a specified HWND. For example, you could use the GetDeskTopWindow to get the Desk Top HWND and then capture the whole desktop to a VB Picture Object.

Screen Shot

Perhaps the best thing about these routines are that they return a standard VB Picture Object. That means that you can incorporate screen capturing routines for many different purposes (and save them to disk with the SavePicture vb statement) - for instance, if your program raises an error, you can capture the screen in your error handling routine and then save it to disk / database / whatever ! - You could even email the saved picture straight to the relevant developer.

Example usage :

  set Picture1.Picture = CaptureForm(me)
  PrintPicture Printer, Picture2.Picture
' or :
  Dim oPic as StdPicture

  set oPic = CaptureWindow(0, 0, 0, _
        Screen.Width / Screen.TwipsPerPixelX, _
        Screen.Height / Screen.TwipsPerPixelY)
  SavePicture oPic.Picture, "c:\output.bmp"

Download Zipped Project and ScreenCapture.BAS module (5k)

This article was originally published on February 5th, 2004

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date