Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: ScreenCapture in Category Microsoft Visual Basic 6 : Graphics from Total Visual SourceBook

Screen capturing windows and forms to a picture with VB6.

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the CScreenCapture class
CaptureType Property Get the current type of screen capture.
Form Property Get a handle to the form used for Form and Client captures.
PictureData Property Get the contents of the most recent screen capture as an OLE Picture data type (which can be send directly to the Picture property of a PictureBox control).
PrintOrientation Property Get the current printer orientation.
Class_Initialize Initialize Initialize internal variables.
Capture Method Captures the object defined by the CaptureType property. Before calling this method, set the CaptureType property to define the object you want to capture.
Clear Method Clear the class picture object.
PrintPicture Method Print the current picture object to the printer specified by the Prn argument. The orientation for printing is based on the PrintOrientation property.
CaptureActiveWindow Private Capture the active window to a Printer object.
CaptureClient Private Capture the form's client area to a Printer object.
CaptureForm Private Capture the passed form to a Printer object.
CaptureScreen Private Capture the entire screen to a Printer object.
CaptureWindowToPicture Private Capture the specified part of a window and returns the data as a picture object.
CreatePictureFromBitmap Private Create a bitmap object from the specified bitmap and palette.
GetBestFit Private Determine the best print orientation for the picture based on a simple height vs. width comparison.

Example Code for Using Class: ScreenCapture

' Example of the CScreenCapture class
'
' To use this example:
' 1.  Create a new form.
' 2.  Create a command button named cmdCaptureScreen
' 3.  Create a command button named cmdCaptureForm
' 4.  Create a command button named cmdCaptureClient
' 5.  Create a command button named cmdCaptureActive
' 6.  Create a command button named cmdPrint
' 7.  Create a command button named cmdClear
' 8.  Create an array of 3 option buttons named optOrientation
' 9.  Create a picture box named picCapture
' 10. Paste the entire contents of this module into the new form's module.

Private ScreenCap As CScreenCapture

Private Sub cmdCaptureScreen_Click()
  ' Comments  : Capture the entire screen

  ScreenCap.CaptureType = ecstScreen
  ScreenCap.Capture

  Set picCapture.Picture = ScreenCap.PictureData

End Sub

Private Sub cmdCaptureForm_Click()
  ' Comments  : Capture the form

  ScreenCap.CaptureType = ecstForm
  ScreenCap.Capture

  Set picCapture.Picture = ScreenCap.PictureData

End Sub

Private Sub cmdCaptureClient_Click()
  ' Comments  : Capture the client area of this form

  ScreenCap.CaptureType = ecstClient
  ScreenCap.Capture

  Set picCapture.Picture = ScreenCap.PictureData

End Sub

Private Sub cmdCaptureActive_Click()
  ' Comments  : Capture the entire active window

  ScreenCap.CaptureType = ecstActive
  ScreenCap.Capture

  Set picCapture.Picture = ScreenCap.PictureData

End Sub

Private Sub cmdPrint_Click()
  ' Comments  : Print the picture

  ' Determine the settings
  If optOrientation(0).Value Then
    ScreenCap.PrintOrientation = prorPortrait

  ElseIf optOrientation(1).Value Then
    ScreenCap.PrintOrientation = prorLandscape

  Else
    ScreenCap.PrintOrientation = prorBestFit

  End If

  ' Do the print job
  ScreenCap.PrintPicture Printer

End Sub

Private Sub cmdClear_Click()
  ' Comments  : Clear the picture

  ScreenCap.Clear
  Set picCapture.Picture = ScreenCap.PictureData

End Sub

Private Sub Form_Load()

  ' Instantiate the class
  Set ScreenCap = New CScreenCapture

  ' Pass this form to the class
  Set ScreenCap.Form = Me
  Call SetupForm

End Sub

Private Sub SetupForm()
  ' Comments  : Sets up the form visuals
  '
  With Me
    .Caption = "CScreenCapture Example"
    .Width = 6120
    .Height = 3645
  End With

  With cmdCaptureScreen
    .Caption = "Capture &Screen"
    .Width = 1995
    .Height = 350
    .Top = 45
    .Left = 0
  End With

  With cmdCaptureForm
    .Caption = "Capture &Form"
    .Width = 1995
    .Height = 350
    .Top = cmdCaptureScreen.Top + cmdCaptureScreen.Height + 100
    .Left = 0
  End With

  With cmdCaptureClient
    .Caption = "Capture &Client"
    .Width = 1995
    .Height = 350
    .Top = cmdCaptureForm.Top + cmdCaptureForm.Height + 100
    .Left = 0
  End With

  With cmdCaptureActive
    .Caption = "Capture &Active"
    .Width = 1995
    .Height = 350
    .Top = cmdCaptureClient.Top + cmdCaptureClient.Height + 100
    .Left = 0
  End With

  With cmdPrint
    .Caption = "&Print"
    .Width = 1995
    .Height = 350
    .Top = cmdCaptureActive.Top + cmdCaptureActive.Height + 100
    .Left = 0
  End With

  With cmdClear
    .Caption = "C&lear"
    .Width = 1995
    .Height = 350
    .Top = 2790
    .Left = 0
  End With

  With optOrientation(0)
    .Caption = "Portrait"
    .Left = 2070
    .Top = 2835
    .Width = 915
    .Value = True
  End With

  With optOrientation(1)
    .Caption = "Landscape"
    .Left = 3420
    .Top = 2835
    .Width = 1200
  End With

  With optOrientation(2)
    .Caption = "Best Fit"
    .Left = 4815
    .Top = 2835
    .Width = 915
  End With

  With picCapture
    .AutoSize = False
    .Left = 2070
    .Height = 2715
    .Width = 3885
    .Top = 45
  End With

End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources