GetPixel with DISPLAY

This is a discussion on GetPixel with DISPLAY within the Windows Programming forums, part of the Platform Specific Boards category; Hi there, Hope you can help me with my latest problem... I'm trying to use GetPixel with the display's DC ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    15

    GetPixel with DISPLAY

    Hi there,

    Hope you can help me with my latest problem...

    I'm trying to use GetPixel with the display's DC to get the COLORREF of the pixels on the whole screen.

    I'm using

    HDC hdc = CreateDC(NULL, "DISPLAY", NULL, NULL);

    to get the HDC for the screen, and then

    COLORREF c = GetPixel(hdc, x, y);

    but when I use GetRValue etc. on c, I always get -1.
    x and y are integers from 0 to 1024 and 768 respectively.

    I've also tried

    CDC* pDC = GetDC();
    COLORREF c = pDC->GetPixel(x,y);

    but the same thing happens. I'm guessing this might be a clipping region issue, but shouldn't the values i gave above be valid for my screen (set to 1024*768) ?

    Cheers for any help you can give,
    Phil Drew.


  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Should be:

    Code:
    HDC hdc = CreateDC("DISPLAY", NULL, NULL,NULL);
    Also, it might be a good idea to check the return value to make sure it's a valid dc.

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    15
    D'oh!

    That's fixed it!
    Thanks a lot!
    P.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. display character size...(quite urgent..)
    By karthi in forum C Programming
    Replies: 10
    Last Post: 07-11-2007, 10:42 PM
  2. new problem with class
    By jrb47 in forum C++ Programming
    Replies: 0
    Last Post: 12-01-2006, 08:39 AM
  3. Help needed Please
    By jereland in forum C Programming
    Replies: 9
    Last Post: 03-18-2004, 05:30 AM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM
  5. Speeding Up Display Time in CEditView :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 04-22-2002, 08:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21