1,486
社区成员
发帖
与我相关
我的任务
分享
BitBlt hdc, rt.Left, rt.Top, rt.Right - rt.Left, rt.Bottom - rt.Top, Picture1.hdc, 0, 0, SRCCOPY
'为picture1添加一个图片,并改变其大小必须要大于QQ登录窗口中的广告窗口
'为该窗口添加如下代码
'测试方法:启动QQ的登录窗口,运行本程序,点击command1按钮
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ChildWindowFromPoint Lib "user32" (ByVal hwnd As Long, ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) 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
'以QQ2008登录窗口为例
Private Sub Command1_Click()
Dim hwnd As Long: pwnd = 0
Dim hdc As Long: pdc = 0
Dim rt As RECT
hwnd = FindWindow(vbNullString, "QQ用户登录") '查找QQ主登录窗口
If hwnd Then '如果找到了
hwnd = ChildWindowFromPoint(hwnd, 10, 10) '取得广告窗口
hdc = GetDC(hwnd)
If hdc Then
GetClientRect hwnd, rt
'picture1为一个Picture控件
BitBlt hdc, rt.Left, rt.Top, rt.Right - rt.Left, rt.Bottom - rt.Top, Picture1.hdc, 0, 0, SRCCOPY
End If
End If
End Sub