Hi everyone!
I want to make a screencapture of my program and put it in a picturebox. Is this possible in vb?
Thanks in advance,
Shell
Printable View
Hi everyone!
I want to make a screencapture of my program and put it in a picturebox. Is this possible in vb?
Thanks in advance,
Shell
btw, i want to do it with code offcourse :D
VB Code:
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 Command1_Click() keybd_event vbKeySnapshot, 1, 0&, 0& End Sub
It is possible, but it requires the use of the API. Sadly, I don't have the code to do it here. A search at www.codehound.com should turn something up for ya.Quote:
Originally posted by Shell
btw, i want to do it with code offcourse :D
That will copy it to the clipboard, not place it in a picturebox.Quote:
Originally posted by Mushroom Realm
VB Code:
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 Command1_Click() keybd_event vbKeySnapshot, 1, 0&, 0& End Sub
Thanks for the adress sheppe, its a good site ;)
Still looking for a way to do this :(
Shell
You do know about VB's clipboard object, do you not?Unfortunately Mushroom's code seems to only capture the form.VB Code:
Picture1.Picture = Clipboard.GetData(2) Picture1.Refresh
Yes, i know how tu use the clipboard, but I dont want to use it now because my program allready uses it for some other data :)
I know about it too; I just regard it as a shortcut hack. :) No offense intended.Quote:
Originally posted by Sastraxi
You do know about VB's clipboard object, do you not?Unfortunately Mushroom's code seems to only capture the form.VB Code:
Picture1.Picture = Clipboard.GetData(2) Picture1.Refresh
Here's a link to a fellow's code that will capture the screen. It will even print it if ya want. It should be enough to get you started. :)Quote:
Originally posted by Shell
Thanks for the adress sheppe, its a good site ;)
Still looking for a way to do this :(
Shell
http://www.thescarms.com/Downloads/Capture.zip
Ah!! Victory!!
I took a look at the program you posted, and made my own function, behold!! ;)
Thanks all :)Code:<script language="vbScript">
<!--
Public Function CaptureScreen(lHwnd as long,lDestDC as long,iScreenWidth as integer,iScreenHeight as integer)
Dim lhDc As Long
lhDc = GetDC(lHwnd )
BitBlt lDestDC , 0, 0, iScreenWidth , iScreenHeight , lhDc, 0, 0, SRCCOPY
//-->
</script>
lol, formatting messed up :D
That's OK Sheppe, just remember, lots of times, the easiest way is sometimes the best.
Sometimes, but not always. In this instance, blowing away the user's clipboard contents could be regarded as a problem. True, a simple backup of the contents would solve that, but then you have to wonder what he wants as far as functionality. Does he want to capture the whole form, or a region of the form. Perhaps he wants to capture the entire screen with the form as it is displayed. There are a lot of factors to consider, and with the prolific amount of code on the net, I would say that the easiest, and most efficient way in this case, would be to find a code example on how to do a proper screen capture, as was done. :)Quote:
Originally posted by Sastraxi
That's OK Sheppe, just remember, lots of times, the easiest way is sometimes the best.
I was merely telling how to capture the clipboard as that's what he asked to do, I'm not condoning it ;)