CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2001
    Posts
    2

    Question reguarding 'Point' command...

    Hi, I'm quite new to VB. I want to be able to get the colour (RGB values) of a pixel at a particular point on the screen for a certain window. I am able to use the Point command to do this for the VB form window, but I need to get the colour of a pixel which is in another window (i.e. another program, NOT my VB project window). Can anyone please help me out, give an example, etc? If so I would much appreciate it.


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Question reguarding 'Point' command...

    You cannot do this using Point. But there is an equivalent API function called GetPixel. The steps in solving your problem are

    Get the handle to the application window using FindWindow().
    Get the device context from this window using GetDC().
    Then use GetPixel() to obtain the pixel color at that point.

    If that does not daunt you ...


  3. #3
    Join Date
    Jun 2001
    Posts
    2

    Re: Question regarding 'Point' command...

    OK thanks a lot for that, I think I can handle using those API functions.
    I just have 1 more question though. The title of the window I want to find is not always the same. The first few words are always the same, but then there is a '-' and some text after it which changes each time (much like the title of an Internet Explorer window, but the other way around). I notice that the FindWindow API does not support partial matches and that it has to find an exact match for the word(s), else it returns a 0 value. Any suggestions about getting around this?


  4. #4
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Question regarding 'Point' command...

    See this post, this might help you.

    http://codeguru.com/cgi-bin/bbs/wt/s...b&Number=40992


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

Featured