Solved

just after properties assigned...

Posted on 2000-03-06
6
160 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 2

Accepted Solution

by:
kotik earned 50 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create Database on Android via Delphi dbExpress 3 88
Multiple image collision 13 74
how can i search if string exist in array ? 3 55
update joined tables 2 45
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 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