VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 获取桌面窗口图象
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:8054, 日期:2001-11-24
获取桌面窗口图象
作者:-
Windows提供了一个API函数GetDesktopWindow,该函数返回桌面窗口的设备描述。 因此利用它就可以轻松获取桌面窗口的图象。
参见下例:
>>步骤1----建立新工程。
>>步骤2----编写如下代码:

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 lDesktop As Long
Dim lDC As Long

Form1.AutoRedraw = True
Form1.ScaleMode = 1
lDesktop = GetDesktopWindow()
lDC = GetDC(lDesktop)
BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, lDC, _
0, 0, vbSrcCopy
End Sub

>>步骤3----编译运行,看看大功告成了吧!