[DUG] Custom component and popup menu
Paul Heinz
paul at accredo.co.nz
Wed May 19 10:33:25 NZST 2010
Hi Rob
> I have some code in my constructor (override)
>
> inherited;
>
> fInternalPopupMenu := nil
>
> if ((csDesigning in ComponentState) = False) then begin
> CreateMenu;
> end;
>
> This code runs fine however my component ALWAYS thinks their
> is no popup assigned so always assigns one. Stepping through
> the code at runtime the Createmenu function is called but the
> component shows popupmenu as nil (even though it has been
> assigned at design time), self.Name even shows as ''.
The object constructors are called by definition _before_ any properties
are streamed in so yes, PopupMenu and Name will always both be unset at
this point.
> I tried moving this to the onMouseDown event but the assigned
> popup, pops up before the event triggers (robbing me the
> opportunity to add my extra options).
>
> Any suggestions on how to do this would be appreciated :)
Without knowing more context, I would suggest a Loaded method override
which is called once all properties are streamed in.
Cheers,
Paul.
More information about the Delphi
mailing list