Stop that Flickering!
Do your applications flicker whilst you update your controls? Find out how to stop it happening with one little-known API call, in this handy copy-and-paste code snippet.
To run, simply copy the below code into a module, then call the LockWindow method, passing the handle (.hWnd property) of the object you want to lock, such as your form or a particular control.
To unlock, simply run the UnlockWindow method.
This code works by calling the LockWindowUpdate API call of User32.dll, which simply 'locks' a form - effectively displaying just the image of it, until an unlock is performed.
Usage
LockWindow(Form1.hWnd) 'Do updating here UnloadWindow
Code
Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWnd As Long) As Long
Public Sub LockWindow(hWnd As Long)
LockWindowUpdate hWnd
End Sub
Public Sub UnlockWindow()
LockWindowUpdate 0
End Sub