Solved

Align : TAlign

Posted on 1998-10-01
9
607 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now