?
Solved

override left property

Posted on 2001-08-07
10
Medium Priority
?
256 Views
Last Modified: 2010-04-06
Hi I'm creating a TGroupbox component and want to get a notification when the left value is changed so.

private
  FLeft: Integer;
  procedure SetLeft(const Value: Integer);
published
  property Left: Integer read FLeft write SetLeft;

procedure TCheckGroupBox.SetLeft(const Value: Integer);
begin
  FLeft := Value;
  inherited Left := Value;

  //Do my stuff
end;

When I place the component on the form the left value is set to 0, how do I set it to the inherited value?
Should I perhaps use a different way than making the left property, the way I do now.
0
Comment
Question by:sorentop
[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
10 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6358921
Such properties are usually set to a generic value in the constructor.
Try overriding the constructor and do a
 FLeft := inherited Left;
This should sync your initialization.
0
 

Author Comment

by:sorentop
ID: 6358979
did not help
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6359019
Did you call "inherited Create(AOwner);" first?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:sorentop
ID: 6359036
I think so, it looks like this

public
constructor Create(AOwner: TComponent); override;

constructor TCheckGroupBox.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FLeft := inherited Left;
end;
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6359138
Try overriding Loaded also.
If that does not work i will have to learn component building.
0
 

Author Comment

by:sorentop
ID: 6359151
Like this...didn't work


protected
  procedure Loaded; override;

procedure TCheckGroupBox.Loaded;
begin
  inherited;
  FLeft := inherited Left;
end;


0
 
LVL 17

Accepted Solution

by:
geobul earned 200 total points
ID: 6359178
Hi,
As you already have FLeft field and Left property defined in the TControl, you just need to override SetLeft procedure:

  private
   procedure SetLeft(Value: Integer);
  public
   constructor Create(AOwner: TComponent); override;
  published
   property Left write SetLeft;
  end;

constructor TCheckGroupBox.Create(AOwner: TComponent);
begin
 inherited Create(AOwner);
end;

procedure TCheckGroupBox.SetLeft(Value: Integer);
begin
  inherited Left := Value;
  // do your stuff here
end;

Regards, Geo
0
 
LVL 3

Expert Comment

by:karouri
ID: 6359332
Listening, and interested in results..
>Try overriding Loaded also.
>If that does not work i will have to learn component building.
I hope that does help. I tried to make a TLine component with special features, and the very thing I needed was to 'overload' the Left and Top properties. e.g. an event OnLeftOrTopChanged or overriding SetLeft and SetTop.
The result I had was that there is no way to do it, for some reason Borland wasn't making such a choice available.

sorentop's needs may be satisfied in another way than 'overriding' Left, but I am offering 250 points if this problem is solved satisfactorily..
0
 

Author Comment

by:sorentop
ID: 6359337
nice
in the constructor isn't couldn't I just write inherited instead of inherited Create(AOwner)
0
 

Author Comment

by:sorentop
ID: 6359399
I have a follow up question if anybody is interrested.
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20164527
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

771 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