Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread .Loaded; or equivalent
Sun, May 10 2015 8:22 PMPermanent Link

MarkB

I need to perform an action after a component's properties are completely streamed in from the form file at run time.  I'd like for it to be at the TComponent level

.AfterLoad looked like what I needed but it doesn't seem to be called like I had hoped.

Is there a method I can override which is called that I can override which is like Delphi's .Loaded method?
Sun, May 10 2015 8:48 PMPermanent Link

MarkB

MarkB wrote:

I need to perform an action after a component's properties are completely streamed in from the form file at run time.  I'd like for it to be at the TComponent level

.AfterLoad looked like what I needed but it doesn't seem to be called like I had hoped.

Is there a method I can override which is called that I can override which is like Delphi's .Loaded method?


Just to make sure what I was attempting worked, I added my own .loaded method here:

procedure TPersistent.LoadProperties(AReader: TReader);
begin
 try
  while (not AReader.EndOfObject) do
     begin
     if (not LoadProperty(AReader)) then
        AReader.SkipProperty;
     if (not AReader.MoreProperties) then
        Break;
     end;

 finally
   Loaded;  <<=======
 end;
end;

But if there is an existing method which is better that would be great.
Sun, May 10 2015 8:53 PMPermanent Link

Raul

Team Elevate Team Elevate

On 5/10/2015 8:22 PM, MarkB wrote:
> I need to perform an action after a component's properties are completely streamed in from the form file at run time.  I'd like for it to be at the TComponent level
> .AfterLoad looked like what I needed but it doesn't seem to be called like I had hoped.
> Is there a method I can override which is called that I can override which is like Delphi's .Loaded method?

Without additional info it's hard to suggest things but i'd suggest
start with InitializeProperties or Initialized


Raul
Sun, May 10 2015 9:02 PMPermanent Link

MarkB

Raul wrote:

On 5/10/2015 8:22 PM, MarkB wrote:
> I need to perform an action after a component's properties are completely streamed in from the form file at run time.  I'd like for it to be at the TComponent level
> .AfterLoad looked like what I needed but it doesn't seem to be called like I had hoped.
> Is there a method I can override which is called that I can override which is like Delphi's .Loaded method?

Without additional info it's hard to suggest things but i'd suggest
start with InitializeProperties or Initialized


Raul


I looked at that but it looks like those are called in the TComponent constructor before properties are streamed in.
Mon, May 11 2015 4:04 AMPermanent Link

Matthew Jones

MarkB wrote:

> I need to perform an action after a component's properties are
> completely streamed in from the form file at run time.  I'd like for
> it to be at the TComponent level
>
> .AfterLoad looked like what I needed but it doesn't seem to be called
> like I had hoped.
>
> Is there a method I can override which is called that I can override
> which is like Delphi's .Loaded method?

Didn't Tim just say that the final version has a way to tell? I can't
find the reference instantly.
Mon, May 11 2015 7:26 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< I need to perform an action after a component's properties are completely streamed in from the form file at run time.  I'd like for it to be at the TComponent level

.AfterLoad looked like what I needed but it doesn't seem to be called like I had hoped. >>

Why is this ?  This is how it gets called:

procedure TPersistent.Load(AReader: TReader);
begin
  BeforeLoad;
  try
     if AReader.IsArray then
        LoadArray(AReader)
     else
        LoadObject(AReader);
     AfterLoad; <<<<<<<<<<<<<<<<<<<<<<<<
  except
     on E: Exception do
        LoadError(E);
  end;
end;
------------

Tim Young
Elevate Software
www.elevatesoft.com
Mon, May 11 2015 9:26 AMPermanent Link

MarkB

Tim Young [Elevate Software] wrote:

Mark,

<< I need to perform an action after a component's properties are completely streamed in from the form file at run time.  I'd like for it to be at the TComponent level

.AfterLoad looked like what I needed but it doesn't seem to be called like I had hoped. >>

Why is this ?  This is how it gets called:

procedure TPersistent.Load(AReader: TReader);
begin
  BeforeLoad;
  try
     if AReader.IsArray then
        LoadArray(AReader)
     else
        LoadObject(AReader);
     AfterLoad; <<<<<<<<<<<<<<<<<<<<<<<<
  except
     on E: Exception do
        LoadError(E);
  end;
end;
------------

Tim Young
Elevate Software
www.elevatesoft.com



This is at the TComponent/TPersistent level, not the form level.

When a Form loads the components that it contains, Load is never called for the component, just LoadProperty/LoadProperties

Thus, AfterLoad is not called for each individual component on the form.
Mon, May 11 2015 1:21 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< When a Form loads the components that it contains, Load is never called
for the component, just LoadProperty/LoadProperties

Thus, AfterLoad is not called for each individual component on the form. >>

This is a "buglet" in the way that the controls/components are being loaded.
I'll make sure that this is fixed, and that will allow you to use the
built-in methods.

Tim Young
Elevate Software
www.elevatesoft.com


Mon, May 11 2015 2:17 PMPermanent Link

MarkB

<<"Tim Young [Elevate Software]" wrote:

Mark,

<< When a Form loads the components that it contains, Load is never called
for the component, just LoadProperty/LoadProperties

Thus, AfterLoad is not called for each individual component on the form. >>

This is a "buglet" in the way that the controls/components are being loaded.
I'll make sure that this is fixed, and that will allow you to use the
built-in methods.

Tim Young
Elevate Software
www.elevatesoft.com>>

Great!  Thank you.


Image