Information générale
Catégorie:
Codage, syntaxe et commandes
>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.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement