Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 7 of 7 total |
Scope with protected and friend |
Tue, Oct 13 2015 12:22 PM | Permanent Link |
Christian Kaufmann | I load language specific data on the fly for different controls.
Since TLink and TLabel have a common base class (TLabelControl) and I want to set Caption and Hint for both. Caption and Hint are protected, so I tried this (works fine in Delphi): type TLabelControlFriend = class(TLabelControl) end; then usage in the code: if c is TLabelControlFriend then begin cL := TLabelControlFriend(c); cL.Caption := txt.GetValue(c.Name); cl.Hint := txt.GetValue(c.Name + '_Hint'); end; But it doesen't work. I have to duplicate my code and type cast to TLabel and TLink separately. I'm not sure, where this fails. Maybe Caption and Hint could be made public in TLabelControl so I can do it without the friend class definition. cu Christian |
Wed, Oct 14 2015 2:13 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Christian,
<< Since TLink and TLabel have a common base class (TLabelControl) and I want to set Caption and Hint for both. Caption and Hint are protected, so I tried this (works fine in Delphi): ..... if c is TLabelControlFriend then begin cL := TLabelControlFriend(c); cL.Caption := txt.GetValue(c.Name); cl.Hint := txt.GetValue(c.Name + '_Hint'); end; What type is the "c" variable defined as ? Are you seeing a compiler error, or does it just not work at runtime ? Tim Young Elevate Software www.elevatesoft.com |
Wed, Oct 14 2015 3:07 PM | Permanent Link |
Christian Kaufmann | Tim Young [Elevate Software] wrote:
> What type is the "c" variable defined as ? Are you seeing a compiler error, or does it just not > work at runtime ? c is a TComponent. I have a for loop over TFormControl.Components[] for this. It compiles, but it does not work at runtime. cu Christian |
Thu, Oct 15 2015 2:26 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Christian,
<< c is a TComponent. I have a for loop over TFormControl.Components[] for this. It compiles, but it does not work at runtime. >> Yeah, you're not going to be able to do what you're trying to do. You can't "crack" protected properties using casting in EWB, like you can in Delphi. Tim Young Elevate Software www.elevatesoft.com |
Sat, Oct 17 2015 2:18 PM | Permanent Link |
Christian Kaufmann | Tim Young [Elevate Software] wrote:
> Yeah, you're not going to be able to do what you're trying to do. You can't "crack" protected > properties using casting in EWB, like you can in Delphi. Ok, no problem. But then couldn't you make Caption and Hint public (not published) in TLabelControl? cu Christian |
Mon, Oct 19 2015 4:25 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Christian,
<< Ok, no problem. But then couldn't you make Caption and Hint public (not published) in TLabelControl? >> I'll have to think about this. The whole reason for having everything be protected (or lower) is to allow component developers to be able to decide *exactly* what they want to be accessible for their descendant controls, and not have any properties/functionality "leak" through. Tim Young Elevate Software www.elevatesoft.com |
Mon, Oct 19 2015 5:38 PM | Permanent Link |
Christian Kaufmann | Tim Young [Elevate Software] wrote:
> I'll have to think about this. The whole reason for having everything be protected (or lower) is > to allow component developers to be able to decide exactly what they want to be accessible for > their descendant controls, and not have any properties/functionality "leak" through. I understand. No problem, it's just a few lines of additional code for now. The number of language dependend controls is not that big. cu Christian |
This web page was last updated on Saturday, January 18, 2025 at 07:39 AM | Privacy PolicySite Map © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |