三度网教程:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

用VB取得桌面窗口图象

时间:2023-7-31作者:未知来源:三度网教程人气:


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----编译运行,看看大功告成了吧!

关键词:  用VB取得桌面窗口图象





Copyright © 2012-2018 三度网教程(http://www.3du8.cn) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版