Dynamically Creating Controls in a Container
Friday, September 24th, 2010In 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.