★★VB初心者質問スレ Part9(´・ω・`)★★
■ このスレッドは過去ログ倉庫に格納されています
0609デフォルトの名無しさん
NGNG自分も作ってみたかったので(・∀・)ツクーテミマシタ!
Option Explicit
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) 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 Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Form_Load()
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Dim lnghWnd As Long, lnghDC As Long
Dim rctPoint As POINTAPI, lngColor As Long
Call GetCursorPos(rctPoint)
lnghWnd = WindowFromPoint(rctPoint.x, rctPoint.y)
Call ScreenToClient(lnghWnd, rctPoint)
lnghDC = GetDC(lnghWnd)
lngColor = GetPixel(lnghDC, rctPoint.x, rctPoint.y)
Me.Caption = "R:" & (&HFF And lngColor) & "G:" & ((&HFF00& And lngColor) \ 256) & _
"B:" & ((&HFF0000 And lngColor) \ 65536)
Call ReleaseDC(lnghWnd, lnghDC)
End Sub
■ このスレッドは過去ログ倉庫に格納されています