Private Declare Function Bitblt Lib "GDI32" _
(Byval HDCDest As Long, Byval XDest As Long, _
Byval YDEST As Long, Byval Nwidth As Long, _
Byval nheight as long, byval hdcsrc as long, _
Byval xsrc as long, Byval Ysrc As long, _
BYVAL DWROP AS long) As long
Private Declare Function Getdc LIB "User32" (BYVAL HWND As Long) AS Long
Private Declare Function GetWindowRect Lib "User32" (Byval HWnd As Long, LPRECT AS REC) AS Long
Private Declare Function GetDesktopWindow Lib "User32" () AS Long
Private Type Rect
LEFT As Long
Top as long
Right As long
Bottom as long
End Type
Private sub carturescreen ()
'Defining variables
DIM HCSCREEN AS Long, HWNDScreen As Long
DIM SRECT AS Rect
Dim Width As Long, Height As Long, HEIGHT AS LONG
'Clear first
Picture1.Autoredraw = true 'This sentence is very important, it uses to automatically scrute the lasting graphics to Picture
Picture1.Picture = loadingPicture ()
'Get the screen handle
HWndScreen = getDesktopWindow ()
'Get the screen size
Call getWindowRect (HWndScreen, SRECT)
Width = SRECT.RIGHT - SRECT.LEFT
HEIGHT = SRECT.BOTTOM - SRECT.TOP
'Get screen device context handle
hcscreen = getdc (hwndscreen)
'Paste the entire screen to Picture1
Call Bitblt (Picture1.hdc, 0, 0, Width, Height, HcScreen, 0, 0, VBSRCCPY)
'Refreshing Picture1
Picture1.refresh
'Save the image to the specified by savapicture, use image properties (it is a persistent graphics handle saved in memory)
SavePicture Picture1.Image, "c: /my.bmp"
End Sub