Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CDC FillSolidRect() behavior?

Posted on 1999-07-29
9
Medium Priority
?
1,880 Views
Last Modified: 2013-11-20
Greetings Experts,

I am drawing text into a CScrollView window. Serial data is streaming in from selectable remote devices. I don't want to invalidate the entire window since that causes annoying flickering, but I want to clear each line before I draw it.

So I started playing with FillSolidRect().

pDC->FillSolidRect( 0, 0, 120, 17, pDC->GetBkColor() );

I expected that to clear out the specifed rectangle but nothing happens. The old text just stays there.

Then if I do:

CString str = "The quick red fox yada yada";
pDC->TextOut( 0, 0, str );

the new string is just written over the old one.

Why didn't FillSolidRect() fill a solid rectangle. Am I asking too much?

Thanks,
NC
0
Comment
Question by:nchenkin
[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
9 Comments
 
LVL 4

Expert Comment

by:mandhjo
ID: 1311967
You could try InvalidateRect passing only the rect where the text is displayed.
0
 

Author Comment

by:nchenkin
ID: 1311968
mandhjo,

The text will probably be displayed on the entire window, but if I InvalidateRect( NULL, TRUE ) in the OnUpdate() function - the normal place to do this I guess - then the entire window is already cleared when I am in the OnDraw() handler where I am trying to clear line by line. The line by line clearing will look much nicer.

NC
0
 
LVL 4

Expert Comment

by:mandhjo
ID: 1311969
Why can't you call InvalidateRect passing the rect you defined above ((0, 0, 120, 17))?
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 

Author Comment

by:nchenkin
ID: 1311970
Again because I call InvalidateRect in the OnUpdate() handler. This forces a WM_PAINT message which I handle in my OnDraw() function. The only reason for calling InvalidateRect is to get me into OnDraw(). Now I want to start my line by line drawing of the entire window.

So the question still is why doesn't FillSolidRect() fill a rectangle??
0
 

Expert Comment

by:xu092098
ID: 1311971
Make sure your rect is big enough. Make sure CDC* is the right pointer. I tried on my machine, it works. Of course I put the stuff in OnDraw(...). Check out other reasons, I'm sure it works.
0
 

Author Comment

by:nchenkin
ID: 1311972
xu,

Well, I tried this:

      int BkColor = pDC->GetBkColor();
      pDC->FillSolidRect( 0, 0, 200, 270, RGB(0,0,0) );
      pDC->SetBkColor( BkColor );
      pDC->TextOut( 0, 0, "Yada Yada" );

so that I could get a nice big black box in the upper right corner of my window. But, no box. The text is there alright. Where did the box go? Jupiter?

The CDC pointer is the one passed into OnDraw() so I assume its right. What other reasons are there? I should be in OPAQUE mode since I never changed it to TRANSPARENT. I'm not even sure if that makes a difference.

Will I get in trouble if I start using the 'F' word around here? Will that help? Do I need to sacrifice a goat?

Maybe I'll the building tinyest of apps to see if that works...

NC

0
 

Author Comment

by:nchenkin
ID: 1311973
The goat is saved!

The problem was I was using a mapping mode of MM_LOENGLISH which was based on a Microsoft example of scrolling text in a CScrollView. I discovered this by creating a new MFC app and FillSolidRect() worked fine. I noticed the MM_TEXT mapping mode that the wizard defaults so I changed mine to that and it now works.

Now, being a newbie to all this, I now need to go look up the difference between MM_TEXT and MM_LOENGLISH. Does anyone want to answer this and why FillSolidRect() doesn't fill in MM_LOENGLISH mode for the points? I'll nuke the question in a couple of days otherwise.

NC
0
 

Accepted Solution

by:
jaguar_sri earned 300 total points
ID: 1311974
MM_LOENGLISH IS DIFFERENT FROM MM_TEXT IN THE HANDLING OF THE LOGICAL COORDINATES.
DEVICE CONTEXT USES THE MAPPING SYSTEM AS PER THE MAPPING MODE. MM_LOENGLISH TREATS UPWARD DIRECTION FOR POSITIVE Y AXIS WHERE AS MM_TEXT DOES THE OPPOSITE.
SO AS WE GO DOWN THE SCREEN MM_LOENGLISH ACCEPTS MORE NEGATIVE VALUES AS CORRECT.
YOU HAVE BEEN GIVING THE POSITIVE COORDINATES IN MM_LOENGLISH MODE THAT IS WHY IT WASNT WORKING.
TRY GIVING NEGATIVE VALUES FOR Y IN DRAWING FUNCTIONS.
0
 

Author Comment

by:nchenkin
ID: 1311975
Yep, I figured that out. Guess I'm troubled that TextOut worked but that the Fill functions didn't. But those are the rules once you learn 'em. It would be nice if someone came out with a decent help system so you could find this stuff out in a timely manner....
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

722 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