Michael Van Canneyt wrote 12 lines
On Thu, 26 Jun 2003, Micha Nelissen wrote:
> The first one is Sender.Parent for sure. But the second one:
> DrawMenuBar wants a handle of the window of the menu which needs to
> be redrawn. Which often happens to be Sender.Owner. What guarantees
> me that Sender.Owner is a TWinControl? It could be a TComponent just
> as well....We're just lucky here that all menuitems on a form are
> owned by the form, but they could have been owned by a TButton just
> as well...no restriction there. How to get the form of the menu it's
> on? It could be a popup menu as well...
AFAIK, the owner should always be the form.
If I may ask, why? The owner is only responsible for memory management, in delphi at least, is this different for the lcl? I don't know what prevents me from writing in TForm1:
Button1 := TButton1.Create(Self)
MenuItem1 := TMenuItem.Create(Button1);
? Maybe not the convention, but I could imagine scenario's where one may group components (for memory management) under a different component than a form.
Micha.