Date: 02-16-2022
Return to Index
created by gbSnippets
'This code reads the pixel color value under the cursort using the GetPixel() API.
'Press down the mouse and drag to the location for which you want the pixel value.
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg, hDesktopDC As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,250,50, %WS_OverlappedWindow To hDlg
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc()
Local pt As PointAPI
Select Case Cb.Msg
Case %WM_LButtonDown
SetCapture hDlg
hDeskTopDC = GetDC(%Null)
Case %WM_MouseMove
If GetCapture = hDlg Then
GetCursorPos pt
Dialog Set Text hDlg, Str$(pt.x) + Str$(pt.y) + Str$(GetPixel(hDesktopDC, pt.x,pt.y))
End If
Case %WM_LButtonUp
ReleaseCapture
ReleaseDC(%Null, hDeskTopDC)
End Select
End Function
'gbs_00872
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm