调用CDC :: FrameRect()或CDC :: Rectangle()或CDC :: FillRect()清除CDC :: DrawText()绘制的文本 [英] Calling CDC::FrameRect() or CDC::Rectangle() or CDC::FillRect() clears the text drawn by CDC::DrawText()
问题描述
我设计了一个自定义TreeView控件,它在调整树的大小时包装树项的文本字符串,为了实现这一点,我绘制了树在OnPaint()处理程序中的项目,我使用CDC :: DrawText()在同一个矩形上绘制文本字符串和CDC :: FillRect()来绘制选定的树项目。在这种情况下,我在FillRect()之后调用DrawText(),所以它工作正常。
现在我想绘制一个Focused项目,为此我尝试使用CDC: :FrameRect()在同一个Rect上,它在清除已绘制的文本后绘制一个边界矩形。我也尝试过使用CDC :: Rectangle()但结果是一样的。
事情是我在绘制文本后调用FrameRect()或Rectangle()在同一个矩形,并丢失文本字符串。
是否有我想念的东西或有人可以解释这些矩形API的工作原理是这样只是首先清除屏幕然后绘制东西。
问候。
Hi,
I design a custom TreeView control that wraps the text string of a tree item when the tree is resized, and to achieve that I draw the tree items in OnPaint() handler, I use CDC::DrawText() to draw the text strings and CDC::FillRect() on the same rectangle to draw a selected tree item. In this case I call DrawText() after the FillRect() so it works fine.
Now I want to draw a Focused item, for that I try with CDC::FrameRect() on the same Rect and it draws a bounding rectangle after clearing the text already drawn. I also tried with CDC::Rectangle() but the result was same.
The thing is I call the FrameRect() or Rectangle() after the text is drawn in the same rectangle, and lose the text string.
Is there something I miss or Could someone please explain whether these rectangle API's works like this only i.e. first clear the screen and then draw the thing.
Regards.
推荐答案
请参阅 CDC :: Rectangle
[ ^ ],特别是矩形的内部使用当前的画笔。。因此,您需要将文本添加为最后一个操作。
See the remarks section under CDC::Rectangle
[^], particularly The interior of the rectangle is filled using the current brush.. So you need to add the text as the very last action.
这篇关于调用CDC :: FrameRect()或CDC :: Rectangle()或CDC :: FillRect()清除CDC :: DrawText()绘制的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!