Jump to content
  • Advertisement
Sign in to follow this  
carloshathcock

Getpixel help. Thanks.

This topic is 4176 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I use visual basic.net 2003 and i would like to read the HEX pixel value of a pixel under my mouse anywhere on my computer (not just in my program). I did this is visual basic 6 but i can not do it in .net. I am using windows API but it will not read the colors at all. Can someone please give me an example of how to read the hex pixel color? I know it is simple, i just cant seem to do it. :( Thanks.

Share this post


Link to post
Share on other sites
Advertisement
I really do not understand. Here are my declared functions form the windows API.


Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long


Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long


Here is the code i am using in a timer:


Dim screen As Long = GetDC(0)
Me.Text = Hex(GetPixel(screen, Cursor.Position.x, Cursor.Position.y))

It is like the GetPixel Command is doing nothing. When a set me.text to the screen = GetDC(0) a bunch of numbers keep flowing so it seems the GetDC is working. Why is GetPixel not working?

Share this post


Link to post
Share on other sites
I have also tried using GetDesktopWindow and using the handel it returns in the GetDC() API. GetDC() still works but GetPixel seems to be not be doing anything.

Share this post


Link to post
Share on other sites
I do not understand what i am doing wrong. I know that i must be doing something wrong, but i do not understand what. Declarations in the GDI library have been tested for years so I know it is my error but i can not put on finger on what i am doing wrong. Please help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!