
Originally Posted by
Antithesus
Any thoughts on why I am getting a -1 back from your routine?
Even when I start at 1 or greater... it still comes back with -1 for the very first GetPixel call.
I finally broke down, made a test project and simplified the FindTop function.
I've tested it and it works fine on a pic box, with or without the boarder.
Code:
Public Function FindTop(ByRef Pic As PictureBox, ByRef BackClr As Long) As Long
Dim lX As Long
Dim lY As Long
Dim cMode As ScaleModeConstants
' 'store the scalemode
cMode = Pic.ScaleMode
'set the picbox to pixels
Pic.ScaleMode = vbPixels
For lY = 0 To Pic.ScaleHeight - 1
For lX = 0 To Pic.ScaleWidth - 1
'search across the row to find a diff colored pixel
If GetPixel(Pic.hDC, lX, lY) <> BackClr Then
FindTop = lY
Exit Function
End If
Next
Next
End Function
I don't know why your getting that -1 on the 1st pixel :/
try this one and see if it works
Edit: spotted a bug, that FindTop = lX needed to be FindTop = lY
I'm always getting my X's and Y's mixed up