2

In my custom control I avoid WM_ERASEBKGND to get rid of flicker. In WM_PAINT handler I first calculate the exact background region and fill it independently. Then I draw text fields with DrawText but when using DT_EXPANDTABS it seems that tab characters (i.e. 0x09) are skipped and not painted and in the end I get visual garbage between words.

Do I have to process tabs manually or is there a flag or setting to force fill the tabs background?

Nik Bougalis
  • 10,495
  • 1
  • 21
  • 37
bkxp
  • 1,115
  • 1
  • 12
  • 20
  • 2
    I don't see a setting or way to get DrawText to fill the background. I think I'd use double buffering -- draw the text to a bitmap filled with your background color, then blit that to the destination. – Jerry Coffin May 30 '13 at 23:43
  • 2
    You can use `DT_CALCRECT` to find out how big the text will be, and then fill the background yourself before drawing the text over the top of it. This doesn't help for multi-line text with a shorter final line however. Using double-buffering as suggested by @JerryCoffin is probably the best solution. – Jonathan Potter May 31 '13 at 03:50
  • My goal is to achieve extreme performance in WM_PAINT. I already use ScrollWindow a lot instead of redrawing, and I take into account the update region. There is no technical problem to use double buffering, but that's a huge performance drop. – bkxp May 31 '13 at 07:53
  • Modern computers are quite fast, I think you'll find the performance from double-buffering is fine and it avoids the flicker problem. – Jonathan Potter May 31 '13 at 08:21
  • "Quite fast" is a nice term for arts, but not for profiling/optimization. I know how to do double buffering, was just curious if it was possible to avoid it by setting some flag in DrawText. It's strange that DrawText treats spaces and tabs differently. Aren't spaces also gaps between words? Anyway, I decided to write custom tab code. This will also add more flexibility with tab positions. – bkxp May 31 '13 at 11:00

0 Answers0