Click here to Skip to main content
15,883,921 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900