Celtic88 Posted June 30, 2013 Share Posted June 30, 2013 (edited) halllo I'm looking for another solution for detect the maximum number OF STRING supported IN A LABEL exempl : expandcollapse popup#include <StaticConstants.au3> $stringsiz = 30 Global $txt $ol = GUICreate("My GUI", 560, 540) $iLabel = GUICtrlCreateLabel("Initial text...", 0, 0, 300, 40, $SS_CENTER) GUICtrlSetBkColor(-1, 0xffffff) GUICtrlSetFont(-1, $stringsiz) $cbou = GUICtrlCreateButton("NEXT", 2, 80, 50, 50) GUISetState() $txt = "abcdefghijklmnopqrstuvwxyzbcdefghijklmnopqrstuvwxyzbcdefghijklmnopqrstuvwxyz" $n = getsiz($ol, $iLabel, $txt) GUICtrlSetData($iLabel, StringLeft($txt, $n)) $txt = StringTrimLeft($txt, $n) Do $msg = GUIGetMsg() If $msg = $cbou Then $n = getsiz($ol, $iLabel, $txt) GUICtrlSetData($iLabel, StringLeft($txt, $n)) $txt = StringTrimLeft($txt, $n) EndIf Until $msg = -3 Func getsiz($zgui, $labctrl, $txtt) Local $a, $oo, $Zz, $iiz = 1, $n, $ppoo $a = ControlGetPos($zgui, "", $labctrl) While 1 For $iiz = $iiz To StringLen($txtt) step 3 $Zz &= StringMid($txtt, $iiz, 3) $oo = _StringSize($Zz, $stringsiz) If $oo[0] >= $a[3] Then ExitLoop Next $ppoo += $oo[1] If $ppoo >= $a[2] Then ExitLoop $n += StringLen($Zz) $Zz = "" WEnd Return $n EndFunc ;==>getsiz Func _StringSize($sString, $iSize = 9, $iWeight = 400, $sFontName = "") Local $hWnd, $hGuiSwitch, $iCtrlID, $aCtrlSize, $aRetSize[2] = [0, 0] $hWnd = GUICreate("StringExInternalWin", 0, 0, 0, 0, BitOR(0x80000000, 0x20000000), BitOR(0x00000080, 0x00000020)) $hGuiSwitch = GUISwitch($hWnd) If $iSize = 65535 Then ; Used by _ImageSize $iCtrlID = GUICtrlCreatePic($sString, 0, 0, 0, 0) Else GUISetFont($iSize, $iWeight, -1, $sFontName, $hWnd) $iCtrlID = GUICtrlCreateLabel($sString, 0, 0) EndIf $aCtrlSize = ControlGetPos($hWnd, "", $iCtrlID) GUIDelete($hWnd) GUISwitch($hGuiSwitch) If IsArray($aCtrlSize) Then $aRetSize[0] = $aCtrlSize[2]; Width $aRetSize[1] = $aCtrlSize[3]; Height Return SetError(0, 0, $aRetSize) EndIf Return SetError(1, 0, $aRetSize) EndFunc ;==>_StringSize thank you Edited June 30, 2013 by Mrbenkali Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 30, 2013 Moderators Share Posted June 30, 2013 Mrbenkali,My StringSize UDF (look in my sig for the link) tells you the dimensions of any string in any font at any size - is that what you want? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Celtic88 Posted June 30, 2013 Author Share Posted June 30, 2013 (edited) Mrbenkali, My StringSize UDF (look in my sig for the link) tells you the dimensions of any string in any font at any size - is that what you want? M23 I do not want to change the size of LABEL , but I want to change the number of characters Edited June 30, 2013 by Mrbenkali Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 30, 2013 Moderators Share Posted June 30, 2013 (edited) Mrbenkali,One of the examples with the UDF determines the largest font size to fit a certain message into a given label size - is that what you are trying to do? M23Edit: Just checked - Example 4 is the one you want. Edited June 30, 2013 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Celtic88 Posted June 30, 2013 Author Share Posted June 30, 2013 (edited) Ah Good I have not seen thank you Edited June 30, 2013 by Mrbenkali Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 30, 2013 Moderators Share Posted June 30, 2013 Mrbenkali,Glad I could help. Just ask if you need any help getting it to work. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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