+ if (msg.message == WM_PAINT)
+ {
+ // NOTE: WM_PAINTs are categorized as wxEVT_CATEGORY_UI
+ if ((eventsToProcess & wxEVT_CATEGORY_UI) == 0)
+ {
+ // this msg is not going to be dispatched...
+ // however WM_PAINT is special: until there are damaged
+ // windows, Windows will keep sending it forever!
+ if (nPaintsReceived > 10)
+ {
+ // we got 10 WM_PAINT consecutive messages...
+ // we must have reached the tail of the message queue:
+ // we're now getting _only_ WM_PAINT events and this will
+ // continue forever (since we don't dispatch them
+ // because of the user-specified eventsToProcess mask)...
+ // break out of this loop!
+ break;
+ }
+ else
+ nPaintsReceived++;
+ }
+ //else: we're going to dispatch it below,
+ // so we don't need to take any special action
+ }
+ else
+ {
+ // reset the counter of consecutive WM_PAINT messages received:
+ nPaintsReceived = 0;
+ }