Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programmatical label's width
Message
From
01/05/1998 15:25:03
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Programmatical label's width
Miscellaneous
Thread ID:
00096378
Message ID:
00096378
Views:
54
I'm porting my FP... I think this one started as far as 1.01... routine for creating little dialog boxes on-the-fly. It works perfectly in VFP, after I've made a little form class to support it, and converted the routine which takes the same old parameters. Now it comes to metrics - the form always looks the same - labels to the left, right aligned, and controls to the right, left aligned, plus a "Alright/Give up" pair of commandbuttons to the bottom right. Well, so it should.

Now the trouble: How can I guess the size of a label if it's AddObject()ed, then given a caption? Since I use foxels, I've come up to

hc=FONTMETRIC(6, g_FontName, g_FontSize)/1.1
< snip >
.width=form1.textwidth(.caption)/hc

and it kind of works with acceptable accuracy, but I'm never too sure if for some font/size/resolution I'll hit the losing combination, like those I've seen while testing (i.e. finding out the best value for the 1.1)- guessing the necessary width used to be wrong up to a factor of two, both up and down. With the present solution I've managed to have between two and five blanks to the left of the longest label, but didn't have the time to test for more resolutions and fonts.

Does anyone know how to set the width of a programmatically created label to exactly the needed width?

I've tried setting the .autosize property, but then I can't know the right moment to set it - is it before or after I set the .fontbold and .caption, or after? It never seems to fire.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Next
Reply
Map
View

Click here to load this message in the networking platform