Results 1 to 3 of 3

Thread: printscreen

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2014
    Location
    Houston, TX
    Posts
    73

    printscreen

    Can anyone tell me how to modify the following code (which I got from this forum) to assign the bitmap to Picture1.picture instead of a file? Thanks.

    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
    ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

    Private Sub cmdBitmap_Click()
    'Use the keybd_event API to do a screen shot.
    'If you only want the active screen, set the second parameter to 1
    keybd_event vbKeySnapshot, 0&, 0&, 0&
    'Yield the processing while the image is copied to clipboard
    DoEvents
    'Save the image on clipboard
    SavePicture Clipboard.GetData(vbCFBitmap), "C:\Users\Owner\Documents\VBasic\printscreen.bmp"
    '**********************
    picture1.picture=???????????????
    '**********************
    End Sub

  2. #2
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: printscreen

    Clipboard.GetData returns a StdPicture
    so just do Picture1.Picture = Clipboard.GetData

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2014
    Location
    Houston, TX
    Posts
    73

    Re: printscreen

    Well, duh! I should have figured that out :-( Thanks.

    BTW - no matter if I code:
    keybd_event vbKeySnapshot, 0&, 0&, 0&
    or
    keybd_event vbKeySnapshot, 1&, 0&, 0&,
    I get the bitmap for form1. How do I get the bitmap for the form where this code executes? Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width