0

I am using NM_CUSTOMDRAW to draw tree view items. My items right justify parts of it by using a right margin based on the RECT area reported available. The issue I have is that when the vertical scrollbar appears or disappears, only the item expanded/collapsed and the area under the scrollbar seems to update (invalidated regions). This causes the repaint requests (with the new width) to not update the area correctly.

For example (using text and a single space as example): You could have something with the scrollbar be right justified text ## where ## is the scrollbar then when the scrollbar goes away you end up with right justified text t instead of right justified text

Is there a good way to fix this?

One thought is if I could catch a message when a scrollbar shows up or goes away, I could just invalidate the window to force a redraw. Is there such a message?

Or is there a way to add to the invalidated region without triggering a redraw loop but would update the full items area?

Another thought is I can just use the full window RECT size and use a right margin large enough that wouldn't be under the scroll area but I'd rather not do that.

Thanks!

user3161924
  • 1,849
  • 18
  • 33
  • When the scrollbar appears or disappears the control will get a `WM_SIZE` message. I would have expected it to do a full repaint at that point. If it's not, for some reason, you could sub-class the control and call `InvalidateRect` manually when you see that message. – Jonathan Potter Dec 20 '22 at 07:57
  • That fixes it. Slight flicker if you keep clicking +/- rapidly but at least it is redrawn correctly. – user3161924 Dec 20 '22 at 21:40

0 Answers0