Solved

just after properties assigned...

Posted on 2000-03-06
6
163 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

718 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