Sign in to follow this  
Followers 0
Celtic88

HEEELP :( GET the maximum number OF STRING supported IN A LABEL

6 posts in this topic

#1 ·  Posted (edited)

halllo ;) I'm looking for another solution for detect the maximum number OF STRING supported IN A LABEL 

exempl :

#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 by Mrbenkali

Share this post


Link to post
Share on other sites



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? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (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? :huh:

M23

I do not want to change the size of LABEL , but I want to change the number of characters

Edited by Mrbenkali

Share this post


Link to post
Share on other sites

#4 ·  Posted (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? :huh:

M23

Edit: Just checked - Example 4 is the one you want. ;)

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ah Good I have not seen  thank you  :)

Edited by Mrbenkali

Share this post


Link to post
Share on other sites

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0