Dynamic Creation of Objects
Posted on 2004-09-15
I need to create DYNAMICALLY some objects within other objects. The pseudocode I want goes something like this:
// on click of a button
For iLoop := 1 to iNoOfPanelsToDo do
// Create a panel
// give it a cyclic name ('panel001')
// set its size and location on the form by Top := iLoop*20 etc.
// Create a child panel on the above panel
// give it a cyclic name ('innerpanel001')
// set its size and location on the form
// Create a button on the innerpanel
// Attach procedure 'InnerButtonPressed' to the button's OnClick event
I've stumbled through the Delphi Help but I cant seem to find anything like this in terms I've guessed to put in the search, yet I suspect it is something the more experienced Delphi people will know like the back of their hand. I did it before ages ago; all I can remember is the bit about accessing the dynamically-created components by name with FindComponent.
Sample code is best; I learn well from plagiarism; oops, I mean example.