Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculate width of the caption
Message
From
14/12/2018 14:14:39
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01664474
Message ID:
01664487
Views:
54
>Hi,
>
>Simplified example.
>I have a check box on a form. The caption of the check box could change (it is data driven). And if the caption is longer than what I set at design time, I want to widen the form. Question: how do you calculate the width or length of a string?
>
>For example, default caption of a check box: "Company". And it may change (at run-time) to being "Company Name". I need to calculate by how much to increase the width when the caption is longer.
>
>TIA

At design, add a width_assign() method. Set autosize = .t..

In the Init() event, save nWidth as startup width. In width_assign(), intercept the new value and adjust up/down based on new width to nWidth comparison, and re-save nWidth.

You'll need the nWidth value to know how it's changed as there's a feature-not-a-bug in VFP that accesses to left, top, width, height will also call assign code as well. There are times the "new width" will be the old width re-stored for some feature-not-a-bug reason.

You can create a custom class for this and use it wherever you need this resize ability. You can also create a discriminating class which will behave in one of N ways based on an nType setting, where nType=1 means resize form, nType=2 means reduce/enlarge font size, etc.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform