From: dan on
After I learned about WM_SETREDRAW in previous post today, I also found
lockwindowupdate fucntion. Can anybody explain difference between
lockwindowupdate () and WM_SETREDRAW? They are similar, based on what I
read in the documentation, and how they both worked with treeview. But
not identical, based on my test with a regular window:

LockWindowUpdate () displays as expected:

LockWindowUpdate (hwnd);
hdc = BeginPaint (hwnd, &ps);
// Painting operations
EndPaint (hwnd, &ps);
LockWindowUpdate (NULL);

WM_SETREDRAW (SetWindowRedraw) just ends up blank:

SetWindowRedraw (hwnd, FALSE);
hdc = BeginPaint (hwnd, &ps);
// Painting operations
EndPaint (hwnd, &ps);
SetWindowRedraw (hwnd, TRUE);

If I move SetWindowRedraw (hwnd, TRUE) inside BeginPaint / EndPaint
block, everything after SetWindowRedraw (hwnd, TRUE) is drawn. The
other changes are perhaps discarded. It seems to me the documentation
should explain the difference. Is LockWindowUpdate for regular
"windows", WM_SETREDRAW for listboxes and treeviews? Petzold, Simon,
and Newcomer books did not explain difference.

Thanks,
Daniel