>Hi
>
>Is there any way to make the width of a command button equal to the width of the caption? Using TXTWIDTH() and the average width of the characters isn't working.
>
>As an example, I'd have the caption "Testing..." on the command button.
>
>When I'm done, I want it to look like this...
> __________
>[Testing...]
> ----------
>
>Setting AutoSize = .T. doesnt work either as it results in something more like this...
> ______________
>[ Testing... ]
> --------------
>
>It seems I'd need to sum the widths of each character and maybe add a little fudge factor.
Would this help :
With thisform.myCommandButton
.Caption = 'Testing...'
tnStyle = Iif(.FontBold,1,0) + ;
Iif(.FontItalic,2,0) + ;
Iif(.FontUnderline,4,0)
lcStyle = Iif( Empty(tnStyle), 'N',;
Iif(Bittest(tnStyle,0),'B','')+;
Iif(Bittest(tnStyle,1),'I','')+;
Iif(Bittest(tnStyle,2),'U','') )
.Width = txtwidth(.Caption, .FontName, .FontSize,lcStyle) * ;
fontmetric(6, .FontName, .FontSize,lcStyle) + ;
Sysmetric(10) * 2
endwith
Cetin