We’ve got a piece of .NET 2.0 software that normally runs under Windows XP (configured in Windows “classic” mode, without the bells and whistles). Now I’m running it on Windows 7 in its full glory. What I’m noticing on Windows 7 is that a certain panel chock-full of labels and layouts within layouts generates all sorts of OnPaint events when the panel gets invalidated. Not only that, but it appears that subsequent OnPaint calls interrupt the currently executing one. Whatever happened to the scheme in which you pull off a message from your window’s message queue, process it to completion, and then pull off the next one?
I’m using the OnPaint method sometimes to configure the layouts, and maybe that’s what is generating the additional OnPaint events, but can’t I at least run the current OnPaint method to completion before the next call is made? I’m having to litter my code with various checks to guard against this reentrancy that’s occurring.
This is not a problem with Windows XP running in classic mode, although it may be a problem in Windows XP running in its full glory.
When you ‘configure’ (change) a layout you Invalidate the control. The Paint event/method is not the right place to change anything. It should only Paint.
When Paint doesn’t cause an Invalidate (and it shouldn’t) this is automatic. When it does then you have a bug that should be fixed.