overflow
04-06-2004, 09:11 AM
Hi.
I'm tring to set a pixel color to red on a form when the detail area is clicked by using the getpixel and setpixel api, but have been unsuccessful as yet. I'm getting a -1 for both getpixel and setpixel which leads me to think that I'm not referencing something properly. Here's the code. Any suggestions? Thanks.
Option Compare Database
Private Type POINTAPI
x As Long 'x coordinate of the mouse
y As Long 'y coordinate of the mouse
End Type
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) 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 SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Sub Detail_Click()
Dim pp As POINTAPI
Dim i As Long
GetCursorPos pp
i = GetPixel(GetDC(GetDesktopWindow), pp.x, pp.y) ' -1 returned
i = SetPixel(GetDC(GetDesktopWindow), pp.x, pp.y, 255) ' -1 returned
End Sub
I'm tring to set a pixel color to red on a form when the detail area is clicked by using the getpixel and setpixel api, but have been unsuccessful as yet. I'm getting a -1 for both getpixel and setpixel which leads me to think that I'm not referencing something properly. Here's the code. Any suggestions? Thanks.
Option Compare Database
Private Type POINTAPI
x As Long 'x coordinate of the mouse
y As Long 'y coordinate of the mouse
End Type
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) 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 SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Sub Detail_Click()
Dim pp As POINTAPI
Dim i As Long
GetCursorPos pp
i = GetPixel(GetDC(GetDesktopWindow), pp.x, pp.y) ' -1 returned
i = SetPixel(GetDC(GetDesktopWindow), pp.x, pp.y, 255) ' -1 returned
End Sub