Thread: SetDCPenColor() undifined

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Put this before you #include <Windows.h>:

    Code:
    #define _WIN32_WINNT 0x0500

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by MacGyver View Post
    Put this before you #include <Windows.h>:

    Code:
    #define _WIN32_WINNT 0x0500
    works, THANX... Didn't know you still exist, will use you on other things

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by csonx_p View Post
    works, THANX... Didn't know you still exist, will use you on other things
    I get no link errors or warnings anymore, but then the color is not changed, always defaults to black... Is there any other form one can change line color when drawing? Here's my code

    Code:
    	// Select the new pen and its color.
    	// Draw the arc using API arc function
    	hPen = (HPEN)GetStockObject(BLACK_PEN);
    	hOldPen=(HPEN)SelectObject(hdc, hPen);
    	SetDCPenColor(hdc,RGB(R,G,B));
    	Arc( hdc, left, top, right, bottom, xstart, ystart, xend, yend 	);
    	SelectObject(hdc, hOldPen);

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I am not sure you can modify a Stock GDI object. YOu would change the default Pen, not select in a Stock Pen and then change the colour.

    I use CreatePen() as it give me more control.


    Code:
    hPen=(HPEN)CreatePen(PS_SOLID,1,RGB(R,G,B));//solid pen one px wide
    
    hOrigPen=SelectObject(hDC,hPen);
    
    //draw
    
    SelectObject(hDC,hOrigPen);
    DeleteObject(hPen);
    Last edited by novacain; 06-18-2008 at 11:49 PM. Reason: clarity
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    610
    Quote Originally Posted by novacain View Post
    I am not sure you can modify a Stock GDI object. YOu would change the default Pen, not select in a Stock Pen and then change the colour.

    I use CreatePen() as it give me more control.


    Code:
    hPen=(HPEN)CreatePen(PS_SOLID,1,RGB(R,G,B));//solid pen one px wide
    
    hOrigPen=SelectObject(hDC,hPen);
    
    //draw
    
    SelectObject(hDC,hOrigPen);
    DeleteObject(hPen);
    Yes this is what i've opted for...works

Popular pages Recent additions subscribe to a feed