The routine I have below I want to get the pixel of the screen. It returns nothing here. If I move the GetPixel call out of the loop, it returns something.

Any idea what I'm doing wrong or a better way of this?

Thanks!

VB Code:
  1. Private Sub Command1_Click()
  2. Dim hDC As Long
  3. Dim H1 As Long
  4. Dim W1 As Long
  5. Dim Z As Long
  6.   H1 = Screen.Height / Screen.TwipsPerPixelY
  7.   W1 = Screen.Width / Screen.TwipsPerPixelX
  8.   Dim X As Long
  9.   Dim Y As Long
  10.   hDC = GetDC(0) 'get desktop dc
  11.  
  12.   For Y = 1 To Y1 - 10
  13.     For X = 1 To H1 - 10
  14.      
  15.       Z = GetPixel(hDC, X, Y)
  16.       Memo1.Text = Memo1.Text & Trim(Str(Z))
  17.      
  18.     Next X
  19.   Next Y
  20.  
  21. End Sub