Link to home
Start Free TrialLog in
Avatar of jhum
jhum

asked on

RGB Help

Can anybody tell me why this ALWAYS draws a black Polygon even if I change the value in : vpBrush.CreateSolidBrush(1114367)
in the Function below? How do I change the brush to another colour? Also how can I make the brush thicker?

void CLIGHTPIPEView::OnDraw(CDC* pDC)
{
      CLIGHTPIPEDoc* pDoc = GetDocument();
      ASSERT_VALID(pDoc);
      CClientDC dc(this);
      CBrush vpBrush;
      vpBrush.CreateSolidBrush(1114367);
      dc.SelectObject(vpBrush);
      dc.Polyline(vPointArray, 5 );

}
Avatar of chabaud
chabaud

Create and select a CPen instead of a CBrush.

Thanks for your five points !
Avatar of jhum

ASKER

It still does not work! I have make the following changes and now it gives the compilation error error C2018: unknown character '0xa0' at this line: CPen vpPen( PS_SOLID , 1, 500 );

void CLIGHTPIPEView::OnDraw(CDC* pDC)
{
      CLIGHTPIPEDoc* pDoc = GetDocument();
      ASSERT_VALID(pDoc);
      CClientDC dc(this);

      CPen vpPen( PS_SOLID , 1, 500 );
         dc.SelectObject(vpPen);
      dc.Polyline(vPointArray, 5 );

      //added till here 23/07
            // TODO: add draw code for native data here
}

The 0xa0 is a high-bit character, not a normal character.  Do you see some weird character on the line?  if so delete it.  If not delete the line and retype it.

Note that pens are for drawing lines.  They have thicknesses.  Brushes are filling in areas, they don't have thicknesses, at least not in the same sense.
Instead of creating your pen that way, how about

CPen vpPen( PS_SOLID, 1, RGB( 0, 255, 128 ));

This is much more documentative instead of 500 or 1114367!!!

Phillip

Another problem with your code, you need to select your pen back when you're done.

CPen vpPen( PS_SOLID, 1, RGB( 0, 255, 128 ));
CPen* pOldPen = (CPen*) dc.SelectObject( &vpPen );
.
dc.SelectObject( pOldPen );

Phillip



Did one of us get your problem solved for you?  If so, respond back and say "Hey netoid" or "Hey Chabaud", "You got it", please respond with an answer and I'll give you the points.  It's only five points anyway!  Don't keep the suspense going!

Phillip

p.s.  You'll get that 0xa0 if you do a copy and paste from these screens.  Just delete the white spaces before and after that line and that bug should go away.


>> p.s.  You'll get that 0xa0 if you do a copy and paste from these screens.  
>> Just delete the white spaces before and after that line and that bug
>> should go away.

I've never seen that happen.  But I've seen EE clients have the problem before.  It must depend on the browser or word processor.  That is good to know though.  thanks.
Personal experience, I copied source code over from the site just last night and I got about 20 of them!

Using Internet Explorer 4.0, did a 'Edit-Select All' and pasted the whole thing into Visual Studio 5.0.

Glad to tell an expert something!!! :)

Phillip


Avatar of jhum

ASKER

Hi Phillip,

Your help with creating the pen worked. I spent a whole lot of time trying to delete lines, spaces and what not, but nothing seems to be getting 0xa0 from that line. Anyway I got around it by redoing the project! It was just a little one so it's okay. Thanks for the help with the CPen. And here are your five points
He needs to answer the question (with a "dummy answer) and then you can grade his "true" answer.
ASKER CERTIFIED SOLUTION
Avatar of psdavis
psdavis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can I get these five jhum?

And quit grading 5 pointers with a 'C'!  

Phillip