Sign in to follow this  
Followers 0
FinalVersion

Label Control - Width

3 posts in this topic

How can I set the $lblStablePath and $lblBetaPath to auto adjust the width, so the captions fits?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$frmMain = GUICreate("AutoIt Info", 333, 192, 192, 124)
$Group1 = GUICtrlCreateGroup("Current Installation", 5, 5, 320, 180)
$Group2 = GUICtrlCreateGroup("Stable", 15, 25, 305, 75)
$lbl1 = GUICtrlCreateLabel("Version:", 25, 50, 42, 17)
$lblStableVer = GUICtrlCreateLabel("Loading...", 70, 50, 166, 17)
$lbl2 = GUICtrlCreateLabel("Path:", 35, 75, 29, 17)
$lblStablePath = GUICtrlCreateLabel("Loading...", 70, 75, 51, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Beta", 15, 100, 305, 75)
$lbl3 = GUICtrlCreateLabel("Version:", 25, 125, 42, 17)
$lblBetaVer = GUICtrlCreateLabel("Loading...", 70, 125, 51, 17)
$lbl4 = GUICtrlCreateLabel("Path:", 35, 150, 29, 17)
$lblBetaPath = GUICtrlCreateLabel("Loading...", 70, 150, 51, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)

$regPath = "HKLM\Software\AutoIt v3\AutoIt"
$stableVersion  = RegRead($regPath, "Version")
$stablePath     = RegRead($regPath, "InstallDir")
$betaVersion    = RegRead($regPath, "betaVersion")
$betaPath       = RegRead($regPath, "betaInstallDir")

GUICtrlSetData($lblStableVer, $stableVersion)
GUICtrlSetData($lblStablePath, $stablePath)
GUICtrlSetData($lblBetaVer, $betaVersion)
GUICtrlSetData($lblBetaPath, $betaPath)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



FinalVersion,

I think this will help you: :(

[
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$spath = "C:\I am a very long path\Which needs to be\Shortened to fit\In the label.txt"

$hGUI = GUICreate("Test", 500, 500)

GUICtrlCreateLabel($sPath, 10,  10, 300, 30, $DT_PATH_ELLIPSIS)
GUICtrlCreateLabel($sPath, 10,  50, 300, 30, $DT_END_ELLIPSIS)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Just set your label to the max width possible in your GUI and let Windows sort it out. :) Using GUICtrlRead on the label will return the full path.

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