An erase event is sent when a window's background needs to be repainted.
On some platforms, such as GTK+, this event is simulated (simply generated just before the paint event) and may cause flicker. It is therefore recommended that you set the text background colour explicitly in order to prevent flicker. The default background colour under GTK+ is grey.
To intercept this event, use the EVT_ERASE_BACKGROUND macro in an event table definition.
You must call wxEraseEvent::GetDC and use the returned device context if it is non-NULL. If it is NULL, create your own temporary wxClientDC object.

Derived from


Include files


Event table macros

To process an erase event, use this event handler macro to direct input to a member function that takes a wxEraseEvent argument.
Process a wxEVT_ERASE_BACKGROUND event.


Use the device context returned by GetDC to draw on, don't create a wxPaintDC in the event handler.

See also

Event handling overview



wxEraseEvent(int id = 0, wxDC* dc = NULL)


wxDC* GetDC() const
Returns the device context associated with the erase event to draw on.