Belini Posted July 10, 2017 Share Posted July 10, 2017 I wanted to show the centralized events in the combobox, is there a way to centralize the text? My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
n3wbie Posted July 10, 2017 Share Posted July 10, 2017 On searching forum what i could find is this Link to comment Share on other sites More sharing options...
Belini Posted July 11, 2017 Author Share Posted July 11, 2017 I also searched a lot before posting but I did not find the solution here the forum! My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Malkey Posted July 11, 2017 Share Posted July 11, 2017 (edited) Here is a method to center text in a combo control. expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> ; Ref: https://www.autoitscript.com/forum/topic/119009-combo-and-format-issue-aligning-text/?do=findComment&comment=827534 Local $data[20] Local $iComboWidth = 249 Local $gui = GUICreate('', 260, 410) Local $test = GUICtrlCreateCombo('', 0, 0, $iComboWidth, 400, $WS_VSCROLL) GUICtrlSetFont(-1, 10, Default, Default, "Consolas") ; <<<<<<<<<<<<<<<< From above https reference thread. GUISetState() ; ---- Generate data --------- For $i = 0 To UBound($data) - 1 For $j = 0 To Random(2, 10) $data[$i] &= Random(1, 10, 1) Next Next ; ---- End of Generate data --------- _CentreData($iComboWidth, $data) ; Set data to the control. For $i = 0 To UBound($data) - 1 GUICtrlSetData($test, $data[$i]) Next While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then MsgBox(0, "", "Selected: " & StringStripWS(GUICtrlRead($test), 3), 4) ; $STR_STRIPLEADING (1) = strip leading white space plus $STR_STRIPTRAILING (2) = strip trailing white space ExitLoop EndIf WEnd ; Centre each item in the $aData array, relative to the $iComboWidth. Func _CentreData($iComboWidth, ByRef $aData) Local $strintest = Int(($iComboWidth / 8.3) / 2) ; Find centre of combo window width 8.3 pixels per character ; Add spaces to each item to Centre text. For $i = 0 To UBound($aData) - 1 While Int(StringLen($aData[$i]) / 2) < $strintest $aData[$i] = ' ' & $aData[$i] & ' ' WEnd Next EndFunc ;==>_CentreData Edited July 11, 2017 by Malkey The If expression and the Until expression were replaced by the one While expression in the _CentreData() function.. Belini 1 Link to comment Share on other sites More sharing options...
Belini Posted July 11, 2017 Author Share Posted July 11, 2017 Thanks for the help @Malkey! My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ 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