There's a container control, a TScrollBox, that parents multiple item controls.
Every item control, being compound itself, contains (parents & owns) a delete button. Pressing the button initiates the deleting of the item control.
The deleting involves freeing the component and so the actual operation should be extrinsic with regard to the item. The question is, what would be the best way to do it?
I actually know of a couple of options:
- a timer with a small interval (which is started with the button click);
- a hidden outside button (to which the mouse down & up messages are posted);
- the form's custom message handler.
While I could confidently implement any of those methods, as I flatter myself, I'm not sure which one would be best. Besides, the timer option seems childish, the hidden button one hackish, and the custom message one a bit overkill. In short, all three seem equally half-acceptable, more or less.
I may simply be prejudiced and don't mind being convinced to the contrary. Still most of all I would like to know what is a common method to use in such cases (maybe something I've been missing all the time).