If you ever think about using [WayBack] LockWindowUpdate function (Windows), then read these first:
- The LockWindowUpdate function disables or enables drawing in the specified window. Only one window can be locked at a time.
- 20040610: [WayBack] Speeding up adding items to a combobox or listbox – The Old New Thing
- 20060220: [WayBack] Why does my program run faster if I click and hold the caption bar? – The Old New Thing
- 20070219: [WayBack] What does LockWindowUpdate do? – The Old New Thing
- 20070220: [WayBack] How is LockWindowUpdate meant to be used? – The Old New Thing
- 20070221: [WayBack] With what operations is LockWindowUpdate meant to be used? – The Old New Thing
- 20070223: [WayBack] Final remarks on LockWindowUpdate – The Old New Thing
- 20100830: [WayBack] On LockWindowUpdate: Locking the taskbar – The Old New Thing
- 20111024: [WayBack] There’s a default implementation for WM_SETREDRAW, but you might be able to do better – The Old New Thing
TL;DR:
Do not use LockWindowUpdate
as the limitation is system wide: Only one Window in the system can be used for
LockWindowUpdate
.
Use WM_SETREDRAW
if you can as LockWindowUpdate
“should only to be called to disable drawing in the window beneath the cursor during a drag and drop operation”: there is only one locked window at a time: There can be only one drag/drop operation active at a time, since there is only one mouse.
Instead of LockWindowUpdate(hwnd)
Use SendMessage(hwnd, WM_SETREDRAW, FALSE, 0)
or
SetWindowRedraw(hwnd, FALSE)
Instead of LockWindowUpdate(NULL)
Use SendMessage(hwnd, WM_SETREDRAW, TRUE, 0)
or
SetWindowRedraw(hwnd, TRUE)
Prototype
BOOL LockWindowUpdate( _In_ HWND hWndLock );
Oh, and it’s not called LockWindowUpdate everywhere: [WayBack] Setting a Visual Studio breakpoint on a Win32 API function in user32.dll – The Entrian Solutions Blog.
–jeroen