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 |
Trying To Use TContentSizer |
Sun, May 27 2018 7:02 PM | Permanent Link |
Frederick Chin | I am trying to use TContentSizer to return the pixel width of a TBaloonLabel caption so that I can set the width dynamically. (I hope Tim will include an AutoSize property in the near future)
In my form, I instantiate the class as follows:- TContentSize = Class(TContentSizer) private // No local data public // Uses just the ancestor class public definitions end; var oSize : TContentSize; Later in the form, I call it as showmessage(IntToStr(oSize.GetWidth(blbName.Font,blbName.Caption))); where blbName is the TBaloonLabel. However, I am receiving an error message of Unable to get property 'getwidth' of undefined or null reference Getwidth seems to be a public method of TContentSizer. What am I doing wrong here? -- Frederick |
Sun, May 27 2018 7:21 PM | Permanent Link |
Ralf Mimoun | Probably a dumb question, but are you sure that oSize points to an instance and is not nil?
Ralf Frederick Chin wrote: I am trying to use TContentSizer to return the pixel width of a TBaloonLabel caption so that I can set the width dynamically. (I hope Tim will include an AutoSize property in the near future) In my form, I instantiate the class as follows:- TContentSize = Class(TContentSizer) private // No local data public // Uses just the ancestor class public definitions end; var oSize : TContentSize; Later in the form, I call it as showmessage(IntToStr(oSize.GetWidth(blbName.Font,blbName.Caption))); where blbName is the TBaloonLabel. However, I am receiving an error message of Unable to get property 'getwidth' of undefined or null reference Getwidth seems to be a public method of TContentSizer. What am I doing wrong here? -- Frederick |
Sun, May 27 2018 8:43 PM | Permanent Link |
Frederick Chin | Ralf Mimoun wrote:
/* Probably a dumb question, but are you sure that oSize points to an instance and is not nil? */ It could be but when I do the following, oSize:=TContentSize.Create(NIL); try TLabel1.Caption:=IntToStr(oSize.GetWidth(blbName.Font,blbName.Caption)); finally oSize.Free; end; I get the following compiler message at the creation method, Cannot create an instance of the class TContentSize when it contains abstract methods. -- Frederick |
Mon, May 28 2018 3:16 AM | Permanent Link |
Uli Becker | Frederick,
> Cannot create an instance of the class TContentSize when it contains abstract methods. TContentSizer contains two methods that are declared as "abstract". From Delphi Basics: "The Abstract directive defines a class method as being implemented only in derived classes. It is abstract in the sense that it is a placeholder - it has no implementation in the current class, but must be implemented in any derived classes." When you create a derived class, you have to override these methods as you can see in WebUI.wbs e.g.: TTextContentSizer = class(TContentSizer) protected function GetDOMWrapStyle(AWrap: Boolean): String; override; procedure ApplyDOMContent(const AContent: String); override; end; THTMLContentSizer = class(TContentSizer) protected function GetDOMWrapStyle(AWrap: Boolean): String; override; procedure ApplyDOMContent(const AContent: String); override; end; Uli |
Mon, May 28 2018 4:15 AM | Permanent Link |
Frederick Chin | Uli,
/* TContentSizer contains two methods that are declared as "abstract". From Delphi Basics: "The Abstract directive defines a class method as being implemented only in derived classes. It is abstract in the sense that it is a placeholder - it has no implementation in the current class, but must be implemented in any derived classes." When you create a derived class, you have to override these methods as you can see in WebUI.wbs e.g.: TTextContentSizer = class(TContentSizer) protected function GetDOMWrapStyle(AWrap: Boolean): String; override; procedure ApplyDOMContent(const AContent: String); override; end; THTMLContentSizer = class(TContentSizer) protected function GetDOMWrapStyle(AWrap: Boolean): String; override; procedure ApplyDOMContent(const AContent: String); override; end; */ Based on the above, I have changed the derived class from TContentSizer to TTextContentSizer since the latter already overrides the abstract methods. I am now able to show the TBalloonLabels in auto sized widths and it looks much better. Thanks. -- Frederick |
Tue, May 29 2018 1:38 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Frederick,
<< I hope Tim will include an AutoSize property in the near future >> This control doesn't have an AutoSize property because it allows for wrapping and already auto-sizes the height when doing so. I'll look into it further, but there's probably a reason why an AutoSize property cannot be implemented. Some of the more complex controls can run into issues with auto-sizing, especially if the elements within the control can be placed in the left, middle, or right. Tim Young Elevate Software www.elevatesoft.com |
Tue, May 29 2018 6:47 PM | Permanent Link |
Frederick Chin | Tim,
/* This control doesn't have an AutoSize property because it allows for wrapping and already auto-sizes the height when doing so. I'll look into it further, but there's probably a reason why an AutoSize property cannot be implemented. Some of the more complex controls can run into issues with auto-sizing, especially if the elements within the control can be placed in the left, middle, or right. */ I think that for the balloon label, there should an AutoSize property that can be turned on if Wrap is off. If I decide to set the caption to only fit in one line, it means that the Wrap will not be used and the AutoSize property can kick in to display the label without the extra spaces (beyond the padding) at the end. In my opinion, it just looks more professional. -- Frederick |
This web page was last updated on Friday, April 26, 2024 at 06:09 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |