例えば、(500,500)の色が赤のときにイベントを起こしたいのですが
colorAのかえってくる値が、数値になってかえってきます。
FF0000とかえってきてほしいのですが・・・・
ペイントで画面を赤く塗り、かえってくるかどうかを確かめているのですが
うまくいきません。
_________________________________________________
Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim hTargetWin As Long '対象のウィンドウのハンドル
Dim hTargetDC As Long 'デバイスコンテキストへのハンドル
hTargetWin = WindowFromPoint(0, 0)
hTargetDC = GetDC(hTargetWin)
Dim colorA As Long
Dim FF0000 As Long
colorA = GetPixel(hTargetDC, 500, 500)
If colorA = FF0000 Then
MsgBox("赤です。")
Else
MsgBox("赤以外です。")
End If
MsgBox(colorA)
ReleaseDC(hTargetDC, hTargetWin)
開発環境はVB.NET2003です。
http://madia.world.coocan.jp/cgi-bin/VBBBS/wwwlng.cgi?print+200602/06020111.txt
に回答が付いて続けるみたい。
ツイート | ![]() |