[DUG] Custom component and popup menu
Trevor
trevorj at ihug.co.nz
Wed May 19 16:05:26 NZST 2010
Probably not an issue for what you are doing, but use the loaded method with
caution:
If you use form inheritance, the Loaded method will be called multiple
times, once for the ancestor, then again for each level of inheritance.
.
Makes sense really, but it can bite.
Trevor
_____
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz] On
Behalf Of Robert martin
Sent: Wednesday, 19 May 2010 11:14 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Custom component and popup menu
Hi Paul
Put it in loaded at it works like a charm. Thanks for the help :)
Rob
On 19/05/2010 10:33 a.m., Paul Heinz wrote:
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.
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
unsubscribe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20100519/39a1cb0a/attachment.html
More information about the Delphi
mailing list