Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

just after properties assigned...

Posted on 2000-03-06
6
Medium Priority
?
165 Views
Last Modified: 2010-04-04

What is the best way to do something with visual component just after it loaded and all of its property assigned? I mean overriding SetParent or something else.

0
Comment
Question by:ITugay
6 Comments
 
LVL 2

Expert Comment

by:PeterLarsen
ID: 2587025
Well, you dont say anything about what your are doing - e.g. design-time, run-time or component writing ??

Please give us some more details !!
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2587028
? agreed with peter
0
 
LVL 9

Author Comment

by:ITugay
ID: 2587085
More details.

I need to check and recalculate some properties of component. It must be done at design-time and run-time too. Text bellow is not exactly what I need but may be used as example:

type
   TMyComponent = class(TEdit)
     ...
     procedure CheckText;
  end;

procedure TMyComponent.CheckText;
begin
    if Text='' then
    begin
       Text:='some text';
       TWinControl(Parent).Width:=100;
    end;
end;

I would like to know: "Where the best place to call  procedure CheckText?". It's only sample. I only need to be sure that all properties of my component already assigned. Parent property -  for sample, it's optionally.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Accepted Solution

by:
kotik earned 200 total points
ID: 2587098
Maybe you are looking for this:

<-- from Delphi VCL Help -->
procedure Loaded; virtual;

Description

The Loaded method allows a component to initialize itself after all its parts have loaded from a stream.

When a Delphi application loads a form from its form file, for example, it first constructs the form component by calling its Create constructor, then reading its property values from the form file, which is a stream. After reading all the property values for all the components, Delphi calls the Loaded methods of each component in the order the components were created. This gives the components a chance to initialize any data that depends on the values of other components or other parts of itself.

Note:      All references to sibling components are resolved by the time Loaded is called. Loaded is the first place that sibling pointers can be used after being streamed in.

<-- End of paste -->

You can override the Loaded method and do what anything you need.

Regards,
Kot.
0
 
LVL 2

Expert Comment

by:PeterLarsen
ID: 2587106
I think what you need is to assign your properties to procedures, like this :

type
TMyComponent = class(TEdit)
private
FMyText : string;
procedure FSetMyText(value : string);
public
 property MyText : string read FMyText write FSetMyText;

end;

procedure TMyComponent.FSetMyText(value : string);
begin
 if Value <>'' then
 begin
  FMyText:=Value;
  //or anything else you want to do
 end;
end;

Regards
Peter
0
 
LVL 9

Author Comment

by:ITugay
ID: 2587131
It's exactly what I need. Usually, I do it overriding method SetParent, but one guy told me that it's not right way. How I can miss Loaded?...

Thanx
Igor.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question