Re: FillSolidRect & DrawText
well it is hard to figure out what you are talking about, but I think you
should look up
CDC::IntersectClipRect
Re: FillSolidRect & DrawText
Ah, thx i will be looking into that.
Basically my problem is as follows (sry for crappy explanation b4, it was 4 am :D).
I need to draw a rectangle at some random x, y. I can draw that rectangle fine. Now i need to draw text overtop of it. When i start drawing text (using DrawText function), i use a loop that will effectively fill the whole screen from top to bottom. This also works fine by itself. Now when i try to do both, the rectangle and the text, for some reason the rectangle gets extended over all of the text. This is really weird, but i think it's something with me not clearing some buffer after i use FillSolidRect, and the DrawText function automatically uses that background for the text?
Is there something of that sort implemented within DrawText/FillSoliRect?
[EDIT]
I did some more debugging, and yep, it's something about the buffer. Basically if i reset the BgColor of the text after i draw the rectangle, the text will overwrite the rectangle with the color specified completely.
Is there a way to draw layers one after another, or will i have to calcualte the text offset that i want to be highlighted and then change the background for that piece of text?
Thx in advance.
Re: FillSolidRect & DrawText
Not sure I fully understand what you want, but I think you can use the same rect that you use for FillSolidRect and create a rectangular region (CreateRectRgn). Then, select that into your DC as a ClipRegion (SelectClipRgn). Now when you draw text (or anything else), your drawing will only occur within that region.
Be sure to select the NULL region to re-enable drawing in the entire DC.
Hope that helps.
Re: FillSolidRect & DrawText
Set the background mode to TRANSPARENT before drawing the text
Code:
pDC->SetBkMode(TRANSPARENT);
pDC->DrawText(strRender, -1, &ScrollRect, DT_TOP|DT_NOPREFIX|DT_SINGLELINE);
Re: FillSolidRect & DrawText
Quote:
Originally Posted by Quell
Hey.
I recently ran into a problem trying to do some custom drawing in a view. (CScrollView derived). I use FillSolidRect to fill a rectangle, and then DrawText to render some text in OnDraw. The problem is that all of the text is set on the background that i set using FillSolidRect as opposed only to the bit that i defined as.
Any ideas why?
Thx in advance.
Yes, that is the normal behaviour.
After using FillSolidRect you have to call CDC::SetBkColor to (re-)set the background color for text outputting funtions. Another solution is to set the bk mode to TRANSPARENT (CDC:SetBkMode(TRANSPARENT) ) since you filled the background alredy ...
Hope this was useful.
With regards
Programartist
Ingo Bochmann