virtual BOOL on_draw(HELEMENT he, UINT draw_type, HDC hdc, const RECT &rc) { if ((DRAW_EVENTS)draw_type != where) return FALSE; // do default draw int w = rc.right - rc.left; int h = rc.bottom - rc.top; if (!surface) { surface = image::create(w, h); redraw = true; } else if (w != surface->width() || h != surface->height()) { delete surface; surface = image::create(w, h); redraw = true; } else if (redraw) surface->clear(); if (redraw) { graphics gx(surface); draw(he, gx, w, h); redraw = false; } surface->blit(hdc, rc.left, rc.top); return default_draw ? TRUE : FALSE; }