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.