sugi Posted September 3, 2008 Share Posted September 3, 2008 (edited) Hello,I need to figure out how to calculate the width that a checkbox needs to have to show the full text. At the same time, wasting space by oversizing them is not an option, because I have to place an input field right next to it.Basically the GUI I have to create looks like the following (with a non-fixed-width font):[ ] Point 1 _____________________ [ ] Point 1.1 ___________________ [ ] Point 1.2 ___________________[ ] Point 2 _____________________Where the underscores stand for the input box. If I know how big the checkboxes are, I can size the input box automatically.How can I calculate how I have to size the checkboxes?Thanks! Edited September 3, 2008 by sugi Link to comment Share on other sites More sharing options...
smashly Posted September 3, 2008 Share Posted September 3, 2008 _MeasureString() function Link to comment Share on other sites More sharing options...
Polyphem Posted September 3, 2008 Share Posted September 3, 2008 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $msg GUICreate("My GUI",200,200) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box $string_checkbox1 = "Teststring a" $string_checkbox2 = "Teststring bbbbbbb" $string_checkbox3 = "Teststring c" GUICtrlCreateLabel("",0,0,200,200) GUICtrlSetBkColor(-1, 0x0000ff) ; Green $checkbox1 = GUICtrlCreateCheckbox($string_checkbox1,10,20,stringlen($string_checkbox1)*6.5,20) $checkbox2 = GUICtrlCreateCheckbox($string_checkbox2,10,40,stringlen($string_checkbox2)*6.5,20) $checkbox3 = GUICtrlCreateCheckbox($string_checkbox3,10,60,stringlen($string_checkbox3)*6.5,20) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() This post will be edited again by Polyphem: Tomorrow, 11:55 AM Link to comment Share on other sites More sharing options...
Polyphem Posted September 3, 2008 Share Posted September 3, 2008 (edited) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $msg GUICreate("My GUI",200,200) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box $string_checkbox1 = "Teststring a" $string_checkbox2 = "Teststring bbbbbbb" $string_checkbox3 = "Teststring c" GUICtrlCreateLabel("",0,0,200,200) GUICtrlSetBkColor(-1, 0x0000ff) ; Blue GUICtrlSetState(-1, $GUI_DISABLE) $checkbox1 = GUICtrlCreateCheckbox($string_checkbox1,10,20,stringlen($string_checkbox1)*6.5,20) $checkbox2 = GUICtrlCreateCheckbox($string_checkbox2,10,40,stringlen($string_checkbox2)*6.5,20) $checkbox3 = GUICtrlCreateCheckbox($string_checkbox3,10,60,stringlen($string_checkbox3)*6.5,20) GUICtrlCreateInput("",10+stringlen($string_checkbox1)*6.5,20,180-stringlen($string_checkbox1)*6.5,20) GUICtrlCreateInput("",10+stringlen($string_checkbox2)*6.5,40,180-stringlen($string_checkbox2)*6.5,20) GUICtrlCreateInput("",10+stringlen($string_checkbox3)*6.5,60,180-stringlen($string_checkbox3)*6.5,20) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() Edit: Blue, not Green ... Edited September 3, 2008 by Polyphem This post will be edited again by Polyphem: Tomorrow, 11:55 AM Link to comment Share on other sites More sharing options...
sugi Posted September 3, 2008 Author Share Posted September 3, 2008 (edited) _MeasureString() function Thank you smashly, that seems to be exactly what I was looking for! $string_checkbox1 = "Teststring a" $string_checkbox2 = "Teststring bbbbbbb" $string_checkbox3 = "Teststring c" $checkbox1 = GUICtrlCreateCheckbox($string_checkbox1,10,20,stringlen($string_checkbox1)*6.5,20) $checkbox2 = GUICtrlCreateCheckbox($string_checkbox2,10,40,stringlen($string_checkbox2)*6.5,20) $checkbox3 = GUICtrlCreateCheckbox($string_checkbox3,10,60,stringlen($string_checkbox3)*6.5,20) GUICtrlCreateInput("",10+stringlen($string_checkbox1)*6.5,20,180-stringlen($string_checkbox1)*6.5,20) GUICtrlCreateInput("",10+stringlen($string_checkbox2)*6.5,40,180-stringlen($string_checkbox2)*6.5,20) GUICtrlCreateInput("",10+stringlen($string_checkbox3)*6.5,60,180-stringlen($string_checkbox3)*6.5,20)oÝ÷ Ûú®¢×©ä°ú%Ê^»¶½êÚì"vØh}§!j¸¬^ «y:ò¶¬zËkx,jëh×6$string_checkbox1 = "Teststring IIIIIII" $string_checkbox2 = "Teststring WWWWWWW" Edit: looks like the quick edit function does have a problem with me Edited September 3, 2008 by sugi Link to comment Share on other sites More sharing options...
Polyphem Posted September 3, 2008 Share Posted September 3, 2008 Oh, noch ein Hamburger , na, einen Versuch wars wert (was worth a try)... This post will be edited again by Polyphem: Tomorrow, 11:55 AM Link to comment Share on other sites More sharing options...
rasim Posted September 4, 2008 Share Posted September 4, 2008 More examples Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now