views:

245

answers:

1

I have a CTabCtrl subclass which I'm trying overriding WM_PAINT to perform custom drawing. The only problem is, when I change the selected tab, I get artifacts left on the dialog where the old paint code hasn't been erased before the new code is painted on top. (The standard tab controls have the selected tab appear 2 pixels bigger than non-selected tabs, so when you change from selected to non-selected, you are left with the previous paint artifacts).

What is the best way of "repainting" this area? I've tried getting the parent control's DC and BitBlt'ing that onto the child's DC, but that doesn't work because the parent DC already contains an image of this control.

+2  A: 

Do you override the WM_ERASEBACKGROUND message as well? You should probably do that and erase the area in the control.

You could use DrawThemeParentBackground to draw the background (XP and later) if you don't want to replace all the drawing logic.

Larry Osterman
I handle the message, and return FALSE to do all the drawing in WM_PAINT. I'll try that function now...
Mark Ingram
That worked beautifully - thank you Larry.
Mark Ingram