Solved

RGB Help

Posted on 1998-07-24
12
177 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now