Nothing 2006-3-1 20:59
VB将窗口背景设置成桌面,即抓图
先建立一个窗体,设置窗体的WindowState属性为2,AutoRedraw属性为True
加入API声明,最好加到模块里
[code]
Public Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Public 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
Public Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long
[/code]
在窗体的Form_Load事件中加入下面的代码
[code]
Dim hDC As Long, sX As Integer, sY As Integer
Dim hOldPattern As Long, bBmp(0 To 15) As Byte
Dim hBitmap As Long, hPattern As Long, hDCScreen As Long
sX = Screen.Width Screen.TwipsPerPixelX
sY = Screen.Height Screen.TwipsPerPixelY
hDC = GetDC(0)
'抓图
BitBlt Me.hDC, 0, 0, sX, sY, hDC, 0, 0, vbSrcCopy
ReleaseDC 0, hDC
[/code]