Sep 1st, 2012, 08:26 AM
getpixel() returns -1
This is part of my code:
Private Declare Function GetPixel Lib "GDI32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Sub CommandButtonGenerate_Click()
Dim RefPath As String
RefPath = CommonDialogDraw.Filename
ImageRef.Picture = LoadPicture(RefPath)
MsgBox GetPixel(ImageStud.Picture.Handle, 5, 5)
The getpixel() in my code keeps returning -1. I tried to google and many mentioned that we have to set to vbpixels. Thus i added in this line:
ImageRef.Picture.ScaleMode = vbPixels
But an error "Variable vbPixels is not defined" keeps coming up.
What am i missing? Do i have to declare anything else? I am using VBA.