Thread: Help with error messages

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    43

    Help with error messages

    The function below is supposed to take in integer x and y and then output the value of the pixel.

    Can someone please help identify the cause of the 2 error messages:

    Building getpixel.obj.
    C:\Documents and Settings\christopher\Desktop\getpixel.c(16): error #2048: Undeclared identifier 'XhdcScrn'.

    C:\Documents and Settings\christopher\Desktop\getpixel.c(16): error #2168: Operands of = have illegal types 'int' and 'struct HDC__ *'.

    *** Error code: 1 ***
    Done.

    Code:
    #include <stdio.h>
    #include <windows.h>
    #include <wingdi.h>
    #include <winuser.h>
    
    //get colour of specific pixel
    int getpix(int x, int y){
               
    COLORREF clr;
    HDC      hdcScrn;
    
    XhdcScrn=CreateDC("DISPLAY",0,0,0);
    clr=GetPixel(hdcScrn,x,y); 
    DeleteDC(hdcScrn);
    printf("%i", clr);
    return clr;
    }
    Thankyou :-)

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    The variable XhdcScrn isn't declared anywhere.

Popular pages Recent additions subscribe to a feed