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