Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleCapture an image of a form in a PictureBox
Keywordscapture form image, PrintForm
CategoriesTips and Tricks
 
Simulate Alt-PrintScrn to copy an image of the form to the clipboard. Then paste it into a PictureBox.
 
Private Sub cmdCaptureImage_Click()
#Const WINDOWS_VERSION = "Windows2000"

Dim alt_key As Long
Dim frm As New Form2

    ' Capture an image of the form in the clipboard.
    ' Press Alt.
    alt_key = MapVirtualKey(VK_MENU, 0)
    keybd_event VK_MENU, alt_key, 0, 0
    DoEvents

    ' Press Print Scrn.
    #If WINDOWS_VERSION = "Windows2000" Then
        keybd_event VK_SNAPSHOT, 0, 0, 0
    #Else
        keybd_event VK_SNAPSHOT, 1, 0, 0
    #End If
    DoEvents

    ' Release Alt.
    keybd_event VK_MENU, alt_key, KEYEVENTF_KEYUP, 0
    DoEvents

    frm.Picture1.Picture = Clipboard.GetData(vbCFBitmap)
    frm.Show
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated