?
Solved

Nedd help with CPen.Create

Posted on 1999-11-25
4
Medium Priority
?
697 Views
Last Modified: 2013-11-20
Hiya,
  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

Thanks,
 jer

  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 );

      
0
Comment
Question by:pipe
  • 2
  • 2
4 Comments
 

Author Comment

by:pipe
ID: 2234997
Edited text of question.
0
 
LVL 23

Accepted Solution

by:
chensu earned 400 total points
ID: 2235005
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);
0
 

Author Comment

by:pipe
ID: 2235022
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?

thanks,
 jer
0
 
LVL 23

Expert Comment

by:chensu
ID: 2235036
"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."
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question