Solved

RGB Help

Posted on 1998-07-24
12
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

739 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