Solved

Align : TAlign

Posted on 1998-10-01
9
609 Views
Last Modified: 2012-06-27
I have tried to make a component that derived from TWinControl. And I add property Align, but it didn't work.
Why ?

Regards,
Joely
0
Comment
Question by:joely
9 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 1341407
What is the type of component ?
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1341408
joely

send you align code in for us to take a look at...

Later
BoRiS
0
 

Author Comment

by:joely
ID: 1341409
I just make procedure like this :

procedure SetAlign(Value : TAlign);
begin
  if FAlign <> Value then
  begin
    FAlign := Value;
    Invalidate;
  end;
end;

Joely
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.

 

Accepted Solution

by:
chrismo earned 50 total points
ID: 1341410
The Align property is already created for you - it's just not published in TWinControl. You simply need to redeclare the property in the published section of your component - like TPanel:

extctrls.pas (if you have the VCL source)...

  TPanel = class(TCustomPanel)
  published
    property Align;
    ...
  end;
0
 

Author Comment

by:joely
ID: 1341411
Whereas I think TWinControl has this property but the descends from TWinControl can't use it automatically.
Why ?
Could you given me the reason ?
Or I have to make the procedure self like in extctrls.pas

Regards Joely
0
 

Expert Comment

by:chrismo
ID: 1341412
If I understand you correctly, you said descendants from TWinControl can't use the Align property automatically. I'm not sure why this would be the case.

Again, TPanel descends from TCustomPanel -- TCustomControl -- TWinControl. I don't see any code in these descendants that do anything special - TPanel merely exposes the Align property.

Make sure you are not redefining the entire Align property and field. If you are doing this:

TMyClass = class(TWinControl)
private
  FAlign: TAlign;
  ...
published
  property Align read FAlign write SetAlign;
end;

. then you are overwriting the inherited field and property and it won't work. To use the inherited stuff, you should not define your own field, and do not fully define the property - as follows (refer to TPanel source in VCL if you have it):

TMyClass = class(TWinControl)
private
  // don't put anything here for Align - it's inherited
published
  property Align; // this will merely use the inherited property
  //property Align read FAlign write SetAlign; don't use this!
end;
0
 

Author Comment

by:joely
ID: 1341413
Yes, that's right.
And I also try with color, but how with Caption.
I have still make procedure self.
Thanks.

Regards Joely
0
 

Expert Comment

by:chrismo
ID: 1341414
This one's a bit more complicated - I don't have the time right now to answer in - check out the VCL source if you have it - TControl.GetText and .SetText. Ask a new question to get this one answered
0
 

Author Comment

by:joely
ID: 1341415
Ok, Thanks.
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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 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