Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RGB Help

Posted on 1998-07-24
12
Medium Priority
?
216 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Technology Partners: 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!

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

886 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