VB 如何 获得 设备场景 句柄
发布网友
发布时间:2023-05-04 08:29
我来回答
共1个回答
热心网友
时间:2023-10-27 03:52
例如获取记事本窗口中坐标为10,10的像素颜色。代码如下。坐标可自己修改。
==================
Option Explicit
Dim hDCWindow As OLE_HANDLE, hWndWindow As OLE_HANDLE
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Command1_Click()
hWndWindow = FindWindow(vbNullString, "Notepad")
hDCWindow = GetDC(hWndWindow)
MsgBox Hex(GetPixel(hDCWindow, 10, 10))
End Sub