Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win32 Text Drawing Puzzle

I've got a little text drawing puzzle under Win32. I'm trying to draw some instructions for users of my application at the top of the window.

Please refer to the following window (I've changed the background color on the text so you can see the boundaries)

Demonstration
(source: billy-oneal.com)

I'm currently using DrawTextEx to draw the text to my window, but the problem is that it does not fill the entire RECTangle that I give it. Not drawing that area is just fine, until the window resizes:

Demonstration after resize
(source: billy-oneal.com)

When the text is re wrapped due to the window sizing, because DrawTextEx doesn't clear it's background, these artifacts are leftover.

I tried using FillRect to fill in the area behind the text drawing call, which does eliminate the visual artifacts, but then causes the text to flicker constantly, as it is completely erased and then completely redrawn to the display.

Any ideas on how one might get the area not containing text to be drawn with the background color?

EDIT: I'd like to avoid having to double buffer the form if at app possible.

EDIT2: I solved the problem by only redrawing the text when I detect that the wrapping changes during a resize.

like image 530
Billy ONeal Avatar asked Dec 18 '25 23:12

Billy ONeal


1 Answers

Use double buffering?

Draw everything to a bitmap and draw the bitmap to the window. Flickering is commonly a double buffering issue.

like image 77
Pedery Avatar answered Dec 20 '25 18:12

Pedery



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!