DelphiFAQ Home Search:

Suppress form repaints during calculations

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

Question:

Is there a way to stop an application from painting during heavy calculations?

Answer:

Call LockWindowUpdate() on your MainForm. Your form will not be redrawn and cannot be moved until you unlock it by passing 0 as the window handle.
Note that LockWindowUpdate() does not hide the form nor does it reset the WS_VISIBLE style bit.

Also note that the final call of LockWindowUpdate(0) - which is required to unlock updates - will cause a lot of flicker as it repaints all application's visible windows/ controls.
Use this function with care only when absolutely necessary.

LockWindowUpdate(MainForm.Handle); // pass the handle of window to lock

// heavy calculation here

LockWindowUpdate(0); // unlock it

Comments:

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: