dickep Posted September 7, 2012 Share Posted September 7, 2012 I have a GUI I created that I would like to use for multiple messages. This GUI could then reside on the display and give the user status for what is happening. However, I need to make some labels (the static type) that will be in different lengths. The corresponding data should then be displayed in static form (I found UEZ's StringSize UDF and the _GUILabelSetText function with it). Using the UDF, I can get the data text size to be dynamic, but the left of the created label stays the same. How can I "move" the left starting point of the data label to be about 2 characters right of the end of the "descriptor" label? Thanks E Link to comment Share on other sites More sharing options...
kaotkbliss Posted September 8, 2012 Share Posted September 8, 2012 Have you tried GuiCtrlSetStyle with the $SS_RIGHT option? 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
UEZ Posted September 8, 2012 Share Posted September 8, 2012 Can you show an example code? Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
JScript Posted September 8, 2012 Share Posted September 8, 2012 (edited) @dickepSomething like this:expandcollapse popup; ##### JScript - 23/05/2012 ##### #include <GUIConstantsEx.au3> Example() Func Example() Local $msg, $iLabel GUICreate("My GUI", 360, 240) ; will create a dialog box that when displayed is centered $iLabel = GUICtrlCreateLabel("Initial text...", 10, 30) GUISetState() ; will display an empty dialog box Sleep(2000) _GUILabelSetText($iLabel, "This is the second text into the label control, fit!") Sleep(2000) _GUILabelSetText($iLabel, "This is the third text will be fully visible in label control, Autoit is the best!") ; Run the GUI until the dialog is closed Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE EndFunc ;==>Example Func _GUILabelSetText($iCtrlID, $sText) Local $asSize $asSize = _StringSize($sText) ControlMove("", "", $iCtrlID, Default, Default, $asSize[0], $asSize[1]) Return GUICtrlSetData($iCtrlID, $sText) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _StringSize ; Description ...: Returns the size (in pixels) of an string. ; Syntax.........: _StringSize( "string" [, size [, weight [, fontname ]]] ) ; Parameters ....: string - The string to evaluate the size. ; Size - [Optional] Fontsize (default is 9). ; Weight - [Optional] Font weight (default 400 = normal). ; FontName - [Optional] Font to use (OS default GUI font is used if the font is "" or is not found). ; Requirement(s).: ; Return values .: Success - Returns a 2-element array containing the following information: ; $array[0] = Width ; $array[1] = Height ; Failure - Returns the same array with 0 and sets @error to 1. ; Author ........: jscript ; Example .......: _StringSize( "Text" ) ; =============================================================================================================================== 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]Reference: Regards,João Carlos. Edited September 8, 2012 by JScript http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
dickep Posted September 11, 2012 Author Share Posted September 11, 2012 OK, here is a sample of what I am doing. It is not working like I want and if you run it you can see that the DESCRIPTION labels are not adjusting (or maybe the data labels are not, not sure which to do). expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <IE.au3> Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "Terminate") Global $avArray[500] Global $iteration Dim $countDowner = "************************************************************" Dim $aIE[1] $aIE[0] = 0 DIM $i = 1 Dim $LoopCount = 3 $GUITitle = "Information" #Region ### START Koda GUI section ### Form= $MessageBoard = GUICreate($GUITitle, 441, 109, 192, 124) $Label1 = GUICtrlCreateLabel("label1", 30, 32, 48, 17) $SleepIndicator = GUICtrlCreateLabel("SleepIndicator", 88, 32, 15, 17) $escLabel = GUICtrlCreateLabel("Press ESC to end application", 40, 8, 141, 17) $label3 = GUICtrlCreateLabel("label3", 40, 58, 48, 17) $interationLabel = GUICtrlCreateLabel("interationLabel", 95, 58, 32, 17) $Label4 = GUICtrlCreateLabel("Iteration: ", 40, 85, 48, 17) $LoopCount = GUICtrlCreateLabel("", 90, 85, 20, 17) GUISetState() ; show the form for now. ;~ get the IE windows/tabs open While 1 $oIE = _IEAttach("", "instance", $i) If @error = $_IEStatus_NoMatch Then ExitLoop ReDim $aIE[$i + 1] $aIE[$i] = $oIE $aIE[0] = $i $i += 1 $avArray[$i - 1] = $oIE.LocationURL WEnd ;~ $avArray[0] = $i - 1 While 1 $nMsg = GUIGetMsg() ;~ ====++++++++++++ ;~ test area ;~ $avArray is the array of URL's that IE has open $GUITitle = "URL Processing" WinSetTitle($MessageBoard, "", $GUITitle) _GUILabelSetText($label1, "Processing URL: ") _GUILabelSetText($SleepIndicator, $avArray[1]) _GUILabelSetText($label3, "") _GUILabelSetText($interationLabel, "") sleep(3000) $GUITitle = "URL Processing again" WinSetTitle($MessageBoard, "", $GUITitle) _GUILabelSetText($label1, "Processing URL: ") _GUILabelSetText($SleepIndicator, $avArray[2]) _GUILabelSetText($label3, "") _GUILabelSetText($interationLabel, "") sleep(3000) $GUITitle = "Pausing " WinSetTitle($MessageBoard, "", $GUITitle) _GUILabelSetText($Label4, "Iteration: ") _GUILabelSetText($LoopCount, $iteration) _GUILabelSetText($label1, "Sleeping: ") _GUILabelSetText($label3, "Minutes Left: ") $sleepEnd = 2 for $p = $sleepEnd - 1 to 1 Step -1 ; 5 minute pause $sInd = "" _GUILabelSetText($interationLabel, $p) for $q = 1 to 60 $sInd = $sInd & "*" _GUILabelSetText($SleepIndicator,StringLeft($countDowner, 60 - $q)) sleep(990) Next Next ;~ Exit ;~ ========================= Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _GUILabelSetText($iCtrlID, $sText) Local $asSize $asSize = _StringSize($sText) ControlMove("", "", $iCtrlID, Default, Default, $asSize[0], $asSize[1]) Return GUICtrlSetData($iCtrlID, $sText) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _StringSize ; Description ...: Returns the size (in pixels) of an string. ; Syntax.........: _StringSize( "string" [, size [, weight [, fontname ]]] ) ; Parameters ....: string - The string to evaluate the size. ; Size - [Optional] Fontsize (default is 9). ; Weight - [Optional] Font weight (default 400 = normal). ; FontName - [Optional] Font to use (OS default GUI font is used if the font is "" or is not found). ; Requirement(s).: ; Return values .: Success - Returns a 2-element array containing the following information: ; $array[0] = Width ; $array[1] = Height ; Failure - Returns the same array with 0 and sets @error to 1. ; Author ........: jscript ; Example .......: _StringSize( "Text" ) ; =============================================================================================================================== 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 Func Terminate() Exit 0 EndFunc ;==>Terminate 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