actually what I want to do is make the pushbutton bigger when the different translation is picked from my language menu
I am a little confused on the stuff you gave below

Okay, so the objective is to figure out how long your pushbutton should be. Logically, the length of the control is directly proportional to the length of the text inside, so step one is to figure out how wide your text is. You could use Len to get the number of characters, and then multiply by a constant get an approximation of the length (5 is a good constant for that application), but different characters are different lengths. Five w's in a row is a heck of a lot longer than four i's in a row.

There is an easy way to determine exactly how long a string of text is, measured in pixels. This will be convenient because the length of a pushbutton (and every other object, for that matter) is measured in pixels.

Basically, you get yourself a Graphics instance, which is an area where things get drawn. The easiest way to get one is to make a new picture in memory, and use the Graphics instance inside of it. Then, you ask the Graphics instance how long your string of text would be if you printed it in your picture, given the font and font size.

To make a new picture in memory, use this...
  Dim p As New Picture(1, 1, 32)

To grab the Graphics instance in the picture, use this...
  Dim g As Graphics = p.Graphics

Now, you need to set your font and font size in the Graphics instance so that it knows how big to print things...
  g.TextFont = whatever your font is
  g.TextSize = whatever your font size is

When you store the text font, you are storing a string, such as "Lucida Grande Regular" The standard font on Macs is Lucida Grande. When you store the text size, you are storing an integer, such as 12. The standard font size for the pushbutton is 12.

Now, you ask the Graphics instance how wide your text would be in pixels if you were to print it...
  your text width in pixels = g.StringWidth("whatever your text is")

... And there you have the length of the text inside your pushbutton. To determine how wide the pushbutton itself should be, you need to add 20 pixels to the width of the caption, because there are 10 pixels of stuff on either side of your caption.

And when that's all done, you have the width for your pushbutton. Just store that value in the Width property of the pushbutton and your pushbutton will snap to that size.

HTH
Andrew Keller
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to