Results 1 to 4 of 4

Thread: GetPixel returns only white!?!

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    Prague, Czech Republic
    Posts
    350
    I am using

    c = GetPixel(GetDC(GetDesktopWindow), x, y)

    to obtain a screen image. I used it often, but now it returns only white &HFFFFFF (maybe I was using a little different trick). Where is the problem?

    Thanx
    John

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    The problem might be that you've ran out of resources, because every time you use GetDC, it creates a new device context. What you need to do is to either use ReleaseDC to remove it after use and/or store the handle in a long while you access all the pixels you need, then release it.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    Prague, Czech Republic
    Posts
    350
    I found the trick - I was mispelled!

    Yes! I wrote GetDekstopWindow - a variable equal to 0. And this works. Now I use GetDC(0) and it works beatufil. Why is than the GetDesktopWindow used for?

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    To get the desktop window handle, well you don't need it.
    Just remember to release the DC or your app might screw up your system resources.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width