Solved

RGB Help

Posted on 1998-07-24
12
186 Views
Last Modified: 2012-05-04
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 );

}
0
Comment
Question by:jhum
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 4

Expert Comment

by:chabaud
ID: 1168512
Create and select a CPen instead of a CBrush.

Thanks for your five points !
0
 

Author Comment

by:jhum
ID: 1168513
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
}

0
 
LVL 22

Expert Comment

by:nietod
ID: 1168514
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.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 7

Expert Comment

by:psdavis
ID: 1168515
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

0
 
LVL 7

Expert Comment

by:psdavis
ID: 1168516
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



0
 
LVL 7

Expert Comment

by:psdavis
ID: 1168517
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.


0
 
LVL 22

Expert Comment

by:nietod
ID: 1168518
>> 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.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1168519
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


0
 

Author Comment

by:jhum
ID: 1168520
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
0
 
LVL 22

Expert Comment

by:nietod
ID: 1168521
He needs to answer the question (with a "dummy answer) and then you can grade his "true" answer.
0
 
LVL 7

Accepted Solution

by:
psdavis earned 0 total points
ID: 1168522
Thanks jhum!!

I was able to get rid of the 0xa0 by doing a "Select All" then  Format and also a Untabify.  Then the white spaces went away.

Phillip

(ooohh... five points....!)


0
 
LVL 7

Expert Comment

by:psdavis
ID: 1168523
Can I get these five jhum?

And quit grading 5 pointers with a 'C'!  

Phillip

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

808 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