Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cmd.width = caption.width
Message
From
13/08/2003 13:08:28
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
13/08/2003 11:32:37
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00819802
Message ID:
00819847
Views:
16
>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
Ç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