Thread: using GDI to draw round ended line

  1. #1
    Registered User
    Join Date
    Jun 2006
    Location
    Singapore
    Posts
    18

    Post using GDI to draw round ended line

    I would like to draw round ended lines using GDI but the below solution doesnt works.
    My Compiler doesn't recognize PS_ENDCAP_ROUND and ExtCreatePen.

    Code:
            LOGBRUSH lBrush;
    	DWORD pStyle = PS_GEOMETRIC | PS_ENDCAP_ROUND;
            DWORD pWidth = 16;
    
    	lBrush.lbStyle = BS_SOLID;
            lBrush.lbColor = RGB(0,0,0);
           lBrush.lbHatch = 0;
    	HPEN hPen = ExtCreatePen(pStyle, pWidth, &lBrush, NULL, NULL);
    	OldHPen = (HPEN)SelectObject(DrawingBuffer,hPen)
    Can anyone point out what I have miss out here? Thanks.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Should be in the Windows board.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    201
    check in your compiler's include directory if PS_ENDCAP_ROUND exists. If not, you might have an old compiler or incorrect library. if it does there might be some #ifdef's around it.
    What compiler you using anyway? I see on MSVC6 (which is pretty old) that it has existed for a long time

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Moved
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jun 2006
    Location
    Singapore
    Posts
    18
    I am using visual studio 2005
    I found out that the compiler's include directory for my app does not define the PS_ENDCAP_ROUND. (C:\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\PocketPC2003\Include\wingdi.h)

    On the other hand, I found that it is defined in C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\WinGDI.h

    Does it mean that pocketPC cannot use PS_ENDCAP_ROUND? Thanks.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Jun 2006
    Location
    Singapore
    Posts
    18
    Thanks Salem.
    Actually, i need the round ended option to fix some broken lines of my app.
    The n points line is form by n-1 segments where the joining appears broken when i increase the pen thickness. My another attempt was to draw eclipse at the line end but not successful.
    I am using the MoveToEx() and LineTo() function.
    Besides Polygonline, is there other methods to solve this problem? thanks.

  8. #8
    Registered User
    Join Date
    Jun 2004
    Posts
    201
    btw, next time search google for "PS_ENDCAP_ROUND windows CE" or something. First hit would've told you. And specify what compiler and platform you use immediately if you think it could be related to that

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Read the manual, figure out what is and isn't allowed, and then figure out an answer.

    Eg. work out the "round endcaps" algorithm yourself and draw them.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fastest way to draw a vertical line
    By CrazyNorman in forum Game Programming
    Replies: 7
    Last Post: 10-17-2006, 09:59 AM
  2. problem with drawnin a user-defined line
    By Isometric in forum Windows Programming
    Replies: 3
    Last Post: 02-12-2002, 11:00 PM
  3. Greenhand want help!
    By leereg in forum C Programming
    Replies: 6
    Last Post: 01-29-2002, 06:04 AM
  4. SSCANF help
    By mattz in forum C Programming
    Replies: 7
    Last Post: 12-10-2001, 04:53 PM
  5. Validating the contents of a char buffer
    By mattz in forum C Programming
    Replies: 3
    Last Post: 12-09-2001, 06:21 PM