Dynamically Creating Controls in a Container
In my current project I dynamically create controls in a container for the settings dialog. I was getting some flicker so I mistakenly used LockWindowUpdate() to solve the problem. I had used this API call years ago, so I knew of it and then discovered via the EMB newsgroups that using LockWindowUpdate() is a common, and very bad practice. Thanks to Karl Pritchett and Remy Lebeau for setting me straight and providing some of the following resource links:
http://blogs.msdn.com/search/SearchResults.aspx?q=LockWindowUpdate§ions=2905
http://msdn.microsoft.com/en-us/library/dd145034(VS.85).aspx
What is surprising is that Delphi’s VCL doesn’t provide a native mechanism to achieve this, and document it as the preferred method. The VCL isolates developers from the WinAPI messages for the most part and this appears to be a fairly common issue from my google searches. If you’ve ever burned time on this, or think it would be a valuable additional to the VCL, consider voting for QC 88375.
September 27th, 2010 at 3:04 pm
Hi, you can use WM_SETREDRAW message to control this.
September 28th, 2010 at 5:00 am
Yes, that’s what this QC item is all about - an additional TWinControl method employing WM_SETREDRAW to effectively LockWindowUpdates for the the control.