Tuesday, July 28, 2009

Desktop capturing

following is the code for a desktop background that will be displayed on the form. First, create a new form and paste the code below:

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()
Dim A As Long
Dim s As Long
Me.AutoRedraw = True
Me.ScaleMode = 1
A = GetDesktopWindow() 'for get background on the desktop
s = GetDC(A)
BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, s, 0, 0, vbSrcCopy
End Sub

Form executed at the time, automatically have a background on the desktop will be displayed on the form.


No comments:

Post a Comment