I want to capture the desktop including all the icons and save it to a file. VB World has an example, but it gives me an error... stack overflow!. HELP!!!
Printable View
I want to capture the desktop including all the icons and save it to a file. VB World has an example, but it gives me an error... stack overflow!. HELP!!!
Code:Declare Function BitBlt Lib "gdi32" _
(ByVal hDestDC As Integer, ByVal x As Integer, _
ByVal y As Integer, ByVal nWidth As Integer, _
ByVal nHeight As Integer, ByVal _
hSrcDC As Integer, ByVal xSrc As Integer, _
ByVal ySrc As Integer, ByVal dwRop As _
Long) As Integer
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function GetDC Lib "user32" _
(ByVal hwnd As Long) As Long
Sub Grabscreen(Dest As PictureBox)
Dim DeskhWnd As Long, DeskDC As Long
'Get the hWnd of the desktop
DeskhWnd = GetDesktopWindow()
'BitBlt needs the DC to copy the image. So, we
'need the GetDC API.
DeskDC = GetDC(DeskhWnd)
Dest.AutoRedraw = True
BitBlt Dest.hDC, 0, 0, _
Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, DeskDC, _
0, 0, vbSrcCopy
Dest.Refresh
End Sub
Thanks 4 trying to help, but I still get stack overflow error both in 640*480 pxl and 800*600 pxl!
That's weird, are you getting the error in the BitBlt line? (that's the only possibility I guess)...
Try my Screenshot demo...
Yes, u r right. Even in the example in the VB-World Graphics section, I am getting the same error
Error: Stack overflow!
If I get things right, I'll post a reply
weird... whats your graphics card?
I got it. I tried the project from screenshot.zip from FOX's website. The only difference was he captured it to a Picture Box. Maybe thats where I got the error
My demos are proofed :)