Nedd help with CPen.Create

  I can't figure out why my createpen is failing. I'm trying to create a green pen with a width of 40 pixels. The create pen method keeps returning 0


  const int GRAPH_HEIGHT = 100;      
      CPen        pen;                              // Pen object
      CRect        rect;
      LOGBRUSH  logBrush ;

      CDC *pDC = GetDC();

      logBrush.lbStyle = PS_SOLID | PS_GEOMETRIC | PS_ENDCAP_SQUARE;

      logBrush.lbColor = RGB( 0, 255, 0 );
      logBrush.lbHatch = 0;
      //Create a green pen
      BOOL bResult = pen.CreatePen( logBrush.lbStyle, 40, &logBrush, 0, NULL );

      // Set the pen.
      pDC->SelectObject( &pen );

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pipeAuthor Commented:
Edited text of question.
logBrush.lbStyle = BS_SOLID;
logBrush.lbColor = RGB(0, 255, 0);
logBrush.lbHatch = 0;

BOOL bResult = pen.CreatePen(PS_SOLID | PS_GEOMETRIC | PS_ENDCAP_SQUARE, 40, &logBrush, 0, NULL);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pipeAuthor Commented:
I gave you another 100 points. I have one more little question first. Using the  PS_ENDCAP_FLAT |PS_ENDCAP_SQUARE flags doesnt seem to make the ends of the lines square or flat. Do you know why this is?

"Windows 95 and Windows 98: The PS_ENDCAP_ROUND, PS_ENDCAP_SQUARE, PS_ENDCAP_FLAT, PS_JOIN_BEVEL, PS_JOIN_MITER, and PS_JOIN_ROUND styles are supported only for geometric pens when used to draw paths."
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.