-
Oct 21st, 2021, 10:39 AM
#1
Thread Starter
Lively Member
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
-
Oct 21st, 2021, 10:45 AM
#2
Re: printscreen
Clipboard.GetData returns a StdPicture
so just do Picture1.Picture = Clipboard.GetData
-
Oct 21st, 2021, 05:01 PM
#3
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|