 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Chris Lock Guest
|
Posted: Thu Feb 05, 2004 5:11 pm Post subject: popup reference |
|
|
Hi -
I'm saving components to a stream, but to save space, I want to remove
all 'Onclick' references etc.
by the following:
with
form1.components[i] do
begin
Onclick:=nil;
....
....
end;
How can I remove references to ancillary components such as popmenu's?
'e.g. popupmenu:=nil;' will not remove the reference inside the saved
stream file to popmenu1 etc.
Thanks in advance,
Chris
|
|
| Back to top |
|
 |
Andreas Schmidt Guest
|
Posted: Thu Feb 05, 2004 5:42 pm Post subject: Re: popup reference |
|
|
"Chris Lock" <chris.lock (AT) kentdesigns (DOT) co.uk> schrieb im Newsbeitrag
news:WOuUb.80879$pD4.1796 (AT) news-lhr (DOT) blueyonder.co.uk...
| Quote: | Hi -
I'm saving components to a stream, but to save space, I want to remove
all 'Onclick' references etc.
by the following:
with
form1.components[i] do
begin
Onclick:=nil;
...
...
end;
How can I remove references to ancillary components such as popmenu's?
'e.g. popupmenu:=nil;' will not remove the reference inside the saved
stream file to popmenu1 etc.
|
Go inside each control using a recusive procedure:
procedure ClearEvents(c:TControl);
var
i : integer;
begin
// do the work
TWinControl(c).OnClick := nil;
// do the work for the nested controls
for i := 0 to c.ControlCount-1 do
ClearEvents(c.Controls[i]);
end;
BTW: only Controls do have a OnClick Event.
Andreas
|
|
| Back to top |
|
 |
Chris Lock Guest
|
Posted: Thu Feb 05, 2004 7:40 pm Post subject: Re: popup reference |
|
|
Thanks, but that wont compile (D7 W98)
TWinControl(c).OnClick := nil; // no onclick
e.g. In a panel, the popupmenu is a reference to an object - how can I
remove the
'popupmenu = form1.popupmenu1' string which occurs in the stream file?
Regards,
Chris
"Andreas Schmidt" <a_j_schmidt (AT) rocketmail (DOT) com> wrote
| Quote: |
"Chris Lock" <chris.lock (AT) kentdesigns (DOT) co.uk> schrieb im Newsbeitrag
news:WOuUb.80879$pD4.1796 (AT) news-lhr (DOT) blueyonder.co.uk...
Hi -
I'm saving components to a stream, but to save space, I want to
remove
all 'Onclick' references etc.
by the following:
with
form1.components[i] do
begin
Onclick:=nil;
...
...
end;
How can I remove references to ancillary components such as
popmenu's?
'e.g. popupmenu:=nil;' will not remove the reference inside the
saved
stream file to popmenu1 etc.
Go inside each control using a recusive procedure:
procedure ClearEvents(c:TControl);
var
i : integer;
begin
// do the work
TWinControl(c).OnClick := nil;
// do the work for the nested controls
for i := 0 to c.ControlCount-1 do
ClearEvents(c.Controls[i]);
end;
BTW: only Controls do have a OnClick Event.
Andreas
|
|
|
| Back to top |
|
 |
Ed Guest
|
Posted: Fri Feb 06, 2004 3:59 pm Post subject: Re: popup reference |
|
|
Hi Chris,
| Quote: | Thanks, but that wont compile (D7 W98)
TWinControl(c).OnClick := nil; // no onclick
|
This won't work since the OnClick is a protected property of TControl
and TWinControl does not widen the visibility. Any component/control
that does have an OnClick has moved the protected property to
published. What you can do is create your own sub-class of TControl
and cast each control as your new subclass: this will give you access
to all the protected members e.g.
new class declaration:
TMyControl= class(TControl);
In loop:
TMyControl(c).OnClick:= nil;
As for the popupmenu, the same is true: it is a protected property of
TControl. Casting as above will allow this property to be set to nil
for any control.
All this is of course untested, but it ought to work. Removing all
the OnClicks when streaming does seam to be a very strange thing to do
though.
HTH,
Ed
|
|
| Back to top |
|
 |
Chris Lock Guest
|
Posted: Fri Feb 06, 2004 4:36 pm Post subject: Re: popup reference |
|
|
Thanks for the info -
What I'm trying to do is to create HMI (for a single board computer)
screens on the fly, by storing each screen as
a file and loading them as the sequence is running. There are no buttons
(these are hardware) or mouse. I only want the
panel of text and shapes to appear. Labels are tagged so I can access
them for changes. Each screen is produced by a separate application and
stored as a filestream. I just wanted to get rid of all the surplus data
in the filestream.
Unless you can think of another way of producing a large number of
individual operator screens??
Regards,
Chriis
"Ed" <contacted2001 (AT) yahoo (DOT) co.uk> wrote
| Quote: | Hi Chris,
Thanks, but that wont compile (D7 W98)
TWinControl(c).OnClick := nil; // no onclick
This won't work since the OnClick is a protected property of TControl
and TWinControl does not widen the visibility. Any component/control
that does have an OnClick has moved the protected property to
published. What you can do is create your own sub-class of TControl
and cast each control as your new subclass: this will give you access
to all the protected members e.g.
new class declaration:
TMyControl= class(TControl);
In loop:
TMyControl(c).OnClick:= nil;
As for the popupmenu, the same is true: it is a protected property of
TControl. Casting as above will allow this property to be set to nil
for any control.
All this is of course untested, but it ought to work. Removing all
the OnClicks when streaming does seam to be a very strange thing to do
though.
HTH,
Ed
|
|
|
| Back to top |
|
 |
J French Guest
|
Posted: Sat Feb 07, 2004 8:32 am Post subject: Re: popup reference |
|
|
On Fri, 06 Feb 2004 16:36:01 GMT, "Chris Lock"
<chris.lock (AT) kentdesigns (DOT) co.uk> wrote:
| Quote: | Thanks for the info -
What I'm trying to do is to create HMI (for a single board computer)
screens on the fly, by storing each screen as
a file and loading them as the sequence is running. There are no buttons
(these are hardware) or mouse. I only want the
panel of text and shapes to appear. Labels are tagged so I can access
them for changes. Each screen is produced by a separate application and
stored as a filestream. I just wanted to get rid of all the surplus data
in the filestream.
Unless you can think of another way of producing a large number of
individual operator screens??
|
That sounds a bit like a cash machine
Have you thought of writing your own screen description system ?
( I assume you have control of both ends of the application )
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|