I created a custom control whose class has CStatic
as base class. Currently I handle the drawing using WM_PAINT
event. But there is a strange behavior. When I re-enable the window after disabling it using CWnd::EnableWindow
function, it refuses to draw what I written in OnPaint
function. It draws the static control instead.
I agree that there is this standard method of overriding DrawItem
and using SS_OWNERDRAW
style. But what's wrong with WM_PAINT
?
void XXControl::OnPaint()
{
CPaintDC PaintDC( this );
// ** draw the control to PaintDC**
}
Here is exactly what I have written:
And subclassed:
Where
IDC_DRAW
is static control on resource for this dialog. I wrote two button handlers:And it works flawlessly! Remove
Invalidate
call and it would fail.Try turning off Aero. I'm having a similiar problem where I'm drawing a static control and when it goes from disabled to enabled the WM_PAINT message is never received, but if I turn Aero off it works fine.