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:



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.

2 Responses to “Dynamically Creating Controls in a Container”

  1. gustavo Says:

    Hi, you can use WM_SETREDRAW message to control this.

  2. Larry Hengen Says:

    Yes, that’s what this QC item is all about - an additional TWinControl method employing WM_SETREDRAW to effectively LockWindowUpdates for the the control.

Leave a Reply