Does anyone know where i can get source that takes apicture of the screen, i.e. a screen shot, without using the Print Screen button ?
Printable View
Does anyone know where i can get source that takes apicture of the screen, i.e. a screen shot, without using the Print Screen button ?
You could use bitblt with the desktop's wnd's DC, into a picturebox which picture you can copy into the clipboard, that does the same
'screen grab...command1 and picture1 required
'
Private Declare Function GetDC Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function StretchBlt Lib _
"gdi32" (ByVal hdc As Long, ByVal x As Long, _
ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, _
ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Sub Command1_Click()
Dim wScreen As Long
Dim hScreen As Long
Dim w As Long
Dim h As Long
Picture1.Cls
wScreen = Screen.Width \ Screen.TwipsPerPixelX
hScreen = Screen.Height \ Screen.TwipsPerPixelY
Picture1.ScaleMode = vbPixels
w = Picture1.ScaleWidth
h = Picture1.ScaleHeight
hdcScreen = GetDC(0)
r = StretchBlt(Picture1.hdc, 0, 0, w, h, hdcScreen, 0, 0, wScreen, hScreen, vbSrcCopy)
End Sub
Stretchblt is slow, if you nessarily needs to youse it, use painpicture instead. Also, why not make a picture with the size of the desktop and then use bitblt with it?
Thanks, i'm not up to speed on bitblt thingy so i'll try that long bit of code first. Thanks to all those of answered though.
i tried that big bit of code, it is extreemly slow or does not work, how do i use paint picture. i got this far
Private Sub Command1_Click()
Picture1.PaintPicture
End Sub
What goes next ?
formorpicturebox.Paintpicture picture,x1,y1,w1,h1,x2,y2,w2,h2,vbsrccopy
Okay this sets the screen shot as the form picture but can easilly be modified:
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function BitBlt Lib "gdi32" _
(ByVal hDestDC As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hSrcDC As Long, _
ByVal xSrc As Long, _
ByVal ySrc As Long, _
ByVal dwRop As Long) As Long
Private Sub Form_Load()
Form1.AutoRedraw = True
Form1.ScaleMode = 1
A = GetDesktopWindow()
s = GetDC(A)
BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, s, 0, 0, vbSrcCopy
End Sub
Right i hope that helps
Cease