Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programmatical label's width
Message
From
01/05/1998 15:38:02
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
01/05/1998 15:25:03
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00096378
Message ID:
00096389
Views:
16
>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.
Dragan,
I think autosize after all other properties is the way to go. After getting height and width with autosize you could turn it off.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform