Click here to Skip to main content
16,017,238 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I'm new to this forum, and I must say I find articles very interesting.

Anyway, I would like some help understanding how the invalidate method as used to invalidate a region on a form deals with multiple requests. I have an application that has several UI classes that I have developed that will invalidate when needed a specified region. I have created a render engine as some UI's are stacked on top of each other, but the problem comes that the invalidate will be called from several UI's before the OnPaint is received, thus changing the region each time and causing update problems. (I have simplified this a bit to save going into the exact details, but this is what happens in real terms.)

My key question is, does the invalidate method queue that regions and the OnPaint response is with respect to the order of the invalidated region? i.e. a FIFO in terms of invalidate/OnPaint behaviour.

Any help would be appreciated.

Thanks

Andy
Posted

Each call to Invalidate() adds the region to the total area that needs repainting. Then when the repaint method is called it will receive details of that total region. Take a look at the MSDN description[^] for more details.
 
Share this answer
 
As Richard said, multiple Invalidate() calls accumulate their invalid regions. However, the documentation does not specify whether it uses the optimal way to accumulate. I recall an old experiment where two non-overlapping rectangles got accumulated to their rectangular hull. As the exact behavior is undocumented, the behavior may change over time, and all you can trust is a sufficient region will be repainted eventually.

:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900