Continuous paint events?

I noticed my app was getting continuous paint events when it was in front, so I made a test app with a single tfDisplay as TextField control. The paint handler for the window is:

Static inc as Integer = 0 inc = inc + 1 tfDisplay.text = str( inc )

This test app also gets a continuous flow of paint events. Is this because changing the value of the tfDisplay text field causes the entire window to refresh when I do that? Or is it typical for all apps to get a continous stream of refresh messages or paint event when the Xojo app is in front?

No it is not typical… normally a Paint Event happens in a limited number of circumstances

  • your app explicitly calls REFRESH or INVALIDATE (Refresh should be used only in rare situtations)
  • something obscures or exposes part of the canvas (including window activates), where the content has become “stale” or invalid

Your tfDisplay should not be causing this to happen, unless that control is overlapping the canvas in which case it may be invoking the 2nd condition I mentioned

In a text field it might be the blinking cursor causing the paint event continuously.

Yes. Making the text field read-only solved the problem. Thanks