Jump to content
Sign in to follow this  
Bert

Lable size depending on text

Recommended Posts

I'm working on a script, and I ran into a problem. I noticed when you change a font size on a label, and you used default sizing to begin with, the label will not resize to show all the text. Take a look at the example below:

#include <GUIConstants.au3>

GUICreate("My GUI")  ; will create a dialog box that when displayed is centered

GUISetHelp("notepad")  ; will run notepad if F1 is typed
Opt("GUICoordMode",2)

$widthCell=70
$1=GUICtrlCreateLabel ("Line 1 Cell 1",  10, 30, $widthCell) ; first cell 70 width
$2=GUICtrlCreateLabel ("Line 2 Cell 1",  -1, 0) ; next line
$3=GUICtrlCreateLabel ("Line 3 Cell 2",  0, 0) ; next line and next cell  
$4=GUICtrlCreateLabel ("Line 3 Cell 3",  0, -1) ; next cell same line 
$5=GUICtrlCreateLabel ("Line 4 Cell 1",  -3*$widthcell, 0) ; next line Cell1

GUICtrlSetFont($3, 12, 900)

GUISetState ()      ; will display an empty dialog box

; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

This is the GUICtrlCreateLabel example from the helpfile, but I added a GUICtrlSetFont to change the 3rd label's font size. How do I get it to reset itself to a size that shows all the text without hardcoding the size requirement? (Do it automatically)

Second question...if I change the text in the label, is it possible to resize it automatically also?

Edited by Volly

Share this post


Link to post
Share on other sites

just playing

#include <GUIConstants.au3>

GUICreate("My GUI")  ; will create a dialog box that when displayed is centered

GUISetHelp("notepad")  ; will run notepad if F1 is typed
;Opt("GUICoordMode",2)

$widthCell=70
$1=GUICtrlCreateLabel ("Line 1 Cell 1",  10, 30, $widthCell) ; first cell 70 width
$2=GUICtrlCreateLabel ("Line 2 Cell 1",  10, 50, $widthCell) ; next line
$3=GUICtrlCreateLabel ("Line 3 Cell 2",  10, 70, $widthCell)
$4=GUICtrlCreateLabel ("Line 3 Cell 3", 10, 90, $widthCell)
$5=GUICtrlCreateLabel ("Line 4 Cell 1", 10, 110, $widthCell)

GUICtrlSetBkColor( $3, 0xff); to see the size of the label

$btn = GUICtrlCreateButton("test", 90, 200, 80, 25)

GUISetState ()      ; will display an empty dialog box

; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
    
    If $msg = $btn Then setsize($3)
    
Until $msg = $GUI_EVENT_CLOSE

Func setsize($control, $font = 12)
    GUICtrlSetFont($control, 12, 900)
    $info = ControlGetPos("My GUI", "", $control)
    $data = GUICtrlRead($control)
    $len = StringLen($data) * ($font/ 4 * 3)
    ControlMove("My GUI", "", $control, $info[0], $info[1], $len, $info[3])
    GUICtrlSetData( $control, $data)
EndFunc

8)

Share this post


Link to post
Share on other sites

just playing

#include <GUIConstants.au3>

GUICreate("My GUI")  ; will create a dialog box that when displayed is centered

GUISetHelp("notepad")  ; will run notepad if F1 is typed
;Opt("GUICoordMode",2)

$widthCell=70
$1=GUICtrlCreateLabel ("Line 1 Cell 1",  10, 30, $widthCell) ; first cell 70 width
$2=GUICtrlCreateLabel ("Line 2 Cell 1",  10, 50, $widthCell) ; next line
$3=GUICtrlCreateLabel ("Line 3 Cell 2",  10, 70, $widthCell)
$4=GUICtrlCreateLabel ("Line 3 Cell 3", 10, 90, $widthCell)
$5=GUICtrlCreateLabel ("Line 4 Cell 1", 10, 110, $widthCell)

GUICtrlSetBkColor( $3, 0xff); to see the size of the label

$btn = GUICtrlCreateButton("test", 90, 200, 80, 25)

GUISetState ()      ; will display an empty dialog box

; Run the GUI until the dialog is closed
Do
    $msg = GUIGetMsg()
    
    If $msg = $btn Then setsize($3)
    
Until $msg = $GUI_EVENT_CLOSE

Func setsize($control, $font = 12)
    GUICtrlSetFont($control, 12, 900)
    $info = ControlGetPos("My GUI", "", $control)
    $data = GUICtrlRead($control)
    $len = StringLen($data) * ($font/ 4 * 3)
    ControlMove("My GUI", "", $control, $info[0], $info[1], $len, $info[3])
    GUICtrlSetData( $control, $data)
EndFunc

8)

Nice. This should do the trick. Thanks!

Share this post


Link to post
Share on other sites

Ok, I designed a script that is a marque. I wrote it so I can change what is posted, and it will resize the control to fit the new text. What is stumping me is how to have it so I have have say 4 controls that scroll at the same time, one after the other, and have the font in different colors for each control.

My goal is to have it so I can have it read off a excel spreadsheet the data I want to scroll. I know how to do that part, but the 4 controls is what is puzzling me at the moment.

edit: a second problem is how do I fix it so when a user maximizes a window, it will show its title bar completely, yet still show my marque? Currently I have it so the marque is in the title bar area. I rather have the marque be a reserved space that no other window can occupy.

current code:

#include <GUIConstants.au3>
#Include <Constants.au3>
HotKeySet("^!z", "_exit")
AdlibEnable('_MoveMarquee', 1)
$size = @DesktopWidth +2 
Global $mygui = GUICreate('my gui', $size, 18, -1, 0, $WS_POPUP, $WS_EX_TOPMOST)
guisetfont(12, 900, 0, "ms comic san",$mygui)
GUISetBkColor ( 0x000000, $mygui )
Global $myl = GUICtrlCreateLabel("Have a great day!", 0, 0)
GUICtrlSetColor($myl, 0xff0000)
GUISetState()
While GUIGetMsg() <> -3
WEnd

Func _MoveMarquee()
    Local $aCpos
    $aCpos = ControlGetPos($mygui, '', $myl)
    If $aCpos[0] >= $size Then  
        setsize($myl)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10      
        $aCpos[0] =  -$lenth        
    endif       
    ControlMove($mygui, '', $myl, $aCpos[0] + 1, $aCpos[1])
EndFunc

func _exit()
exit    
EndFunc

Func setsize($control, $font = 10)
    ;------------------
    ; -section used for testing
    $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9" 
    IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData) 
    $inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users") 
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1] 
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data) 
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc
Edited by Volly

Share this post


Link to post
Share on other sites

I got it so I can now scrool the 4 boxes like I want, and have it different colors. My problem now is when I change the text on the second, third or forth box. You can uncomment out where I make the data change and see what I mean. I'm not sure on how to fix it. Thoughts? Help? ;)

#include <GUIConstants.au3>
#Include <Constants.au3>
HotKeySet("^!q", "_exit")
AdlibEnable('_MoveMarquee', 1)
$size = @DesktopWidth +3 
Global $mygui, $myl, $my2, $my3, $my4, $st
$mygui = GUICreate('my gui', $size, 18, -1, 0, $WS_POPUP, $WS_EX_TOPMOST)
guisetfont(12, 900, 0, "ms comic san",$mygui)
GUISetBkColor ( 0x000000, $mygui )
$myl = GUICtrlCreateLabel("Have a great day!", 0, -2)
$my2 = GUICtrlCreateLabel("****", -150, -1)
$my3 = GUICtrlCreateLabel("****", -300, -1)
$my4 = GUICtrlCreateLabel("****", -450, -1)
GUICtrlSetColor($myl, 0xff0000)
GUICtrlSetColor($my2, 0x00FF00)
GUICtrlSetColor($my3, 0xfff000)
GUICtrlSetColor($my4, 0xffffff)
$st = 1
GUISetState()
While GUIGetMsg() <> -3
WEnd

Func _MoveMarquee()
    Local $aCpos1, $aCpos2, $aCpos3, $aCpos4
    $aCpos1 = ControlGetPos($mygui, '', $myl)
    $aCpos2 = ControlGetPos($mygui, '', $my2)
    $aCpos3 = ControlGetPos($mygui, '', $my3)
    $aCpos4 = ControlGetPos($mygui, '', $my4)
    If $aCpos1[0] >= $size Then  
        setsize1($myl)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10    
        $aCpos1[0] =  -$lenth     
    endif   
    If $aCpos2[0] >= $size Then  
        ;setsize2($my2)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10    
        $aCpos2[0] =  -$lenth     
    endif  
    If $aCpos3[0] >= $size Then  
        ;setsize3($my3)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10    
        $aCpos3[0] =  -$lenth     
    endif
    If $aCpos4[0] >= $size Then  
        ;setsize4($my4)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10    
        $aCpos4[0] =  -$lenth     
    endif   
    ControlMove($mygui, '', $myl, $aCpos1[0] + 1, $aCpos1[1])
    ControlMove($mygui, '', $my2, $aCpos2[0] + 1, $aCpos2[1])
    ControlMove($mygui, '', $my3, $aCpos3[0] + 1, $aCpos3[1])
    ControlMove($mygui, '', $my4, $aCpos4[0] + 1, $aCpos4[1])
EndFunc

func _exit()
exit    
EndFunc

Func setsize1($control, $font = 10)
    ;------------------
    ; -section used for testing
    $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9" 
    IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData) 
    $inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users") 
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1] 
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data) 
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc

Func setsize2($control, $font = 10)
    ;------------------
    ; -section used for testing
   ; $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9" 
    ;IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData) 
    $inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users") 
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1] 
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data) 
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc

Func setsize3($control, $font = 10)
    ;------------------
    ; -section used for testing
    $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9" 
    IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData) 
    $inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users") 
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1] 
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data) 
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc

Func setsize4($control, $font = 10)
    ;------------------
    ; -section used for testing
    $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9" 
    IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData) 
    $inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users") 
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1] 
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data) 
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc

Share this post


Link to post
Share on other sites

This problem has me stumped. I know it is just a matter of getting the boxes in the correct places after the resizing, but how to do that is the ;)

I suspect the solution is putting the 4 controls I have to resize into one, but I'm not sure how to go about it.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#Include <Constants.au3>
HotKeySet("^!q", "_exit")
AdlibEnable('_MoveMarquee', 1)
$size = @DesktopWidth +3
Global $mygui, $myl, $my2, $my3, $my4, $st
$mygui = GUICreate('my gui', $size, 18, -1, 0, $WS_POPUP, $WS_EX_TOPMOST)
guisetfont(12, 900, 0, "ms comic san",$mygui)
GUISetBkColor ( 0x000000, $mygui )
$myl = GUICtrlCreateLabel("Have a great day!", 0, -2)
$my2 = GUICtrlCreateLabel("****", -150, -1)
$my3 = GUICtrlCreateLabel("****", -300, -1)
$my4 = GUICtrlCreateLabel("****", -450, -1)
GUICtrlSetColor($myl, 0xff0000)
GUICtrlSetColor($my2, 0x00FF00)
GUICtrlSetColor($my3, 0xfff000)
GUICtrlSetColor($my4, 0xffffff)
$st = 1
GUISetState()
While GUIGetMsg() <> -3
WEnd

Func _MoveMarquee()
    Local $aCpos1, $aCpos2, $aCpos3, $aCpos4
    Local $stop1, $stop2, $stop3, $stop4 
    $aCpos1 = ControlGetPos($mygui, '', $myl)
    $aCpos2 = ControlGetPos($mygui, '', $my2)
    $aCpos3 = ControlGetPos($mygui, '', $my3)
    $aCpos4 = ControlGetPos($mygui, '', $my4)
    If $aCpos1[0] >= $size and not $stop1 Then 
        setsize1($myl)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10   
        $aCpos1[0] =  -$lenth 
        $stop1 = True
    endif   
    If $aCpos2[0] >= $size and not $stop2 Then 
        ;setsize2($my2)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10   
        $aCpos2[0] =  -$lenth     
    endif 
    If $aCpos3[0] >= $size and not $stop3 Then 
        ;setsize3($my3)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10   
        $aCpos3[0] =  -$lenth     
    endif
    If $aCpos4[0] >= $size and not $stop3 Then 
        ;setsize4($my4)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10   
        $aCpos4[0] =  -$lenth     
    endif   
    ControlMove($mygui, '', $myl, $aCpos1[0] + 1, $aCpos1[1])
    ControlMove($mygui, '', $my2, $aCpos2[0] + 1, $aCpos2[1])
    ControlMove($mygui, '', $my3, $aCpos3[0] + 1, $aCpos3[1])
    ControlMove($mygui, '', $my4, $aCpos4[0] + 1, $aCpos4[1])
EndFunc

func _exit()
exit   
EndFunc

Func setsize1($control, $font = 10)
    ;------------------
    ; -section used for testing
    $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9"
    IniWriteSection(@ScriptDir & "\settings.ini", "users", $sData)
    $inia2= IniReadSection(@ScriptDir & "\settings.ini", "users")
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1]
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data)
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc

Func setsize2($control, $font = 10)
    ;------------------
    ; -section used for testing
   ; $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9"
    ;IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData)
    $inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users")
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1]
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data)
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc

Func setsize3($control, $font = 10)
    ;------------------
    ; -section used for testing
    $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9"
    IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData)
    $inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users")
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1]
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data)
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc

Func setsize4($control, $font = 10)
    ;------------------
    ; -section used for testing
    $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9"
    IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData)
    $inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users")
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1]
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data)
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc

8)

Share this post


Link to post
Share on other sites

Still broke with the same problem. ;)

In the movemarque function, I uncomment the setsize for the different boxes, The windows will pile up on each other.

#include <GUIConstants.au3>
#Include <Constants.au3>
HotKeySet("^!q", "_exit")
AdlibEnable('_MoveMarquee', 1)
$size = @DesktopWidth +3
Global $mygui, $myl, $my2, $my3, $my4, $st
$mygui = GUICreate('my gui', $size, 18, -1, 0, $WS_POPUP, $WS_EX_TOPMOST)
guisetfont(11.5, 900, 0, "ms comic san",$mygui)
GUISetBkColor ( 0x000000, $mygui )
$myl = GUICtrlCreateLabel("Have a great day!", 0, -2)
$my2 = GUICtrlCreateLabel("****", -150, -1)
$my3 = GUICtrlCreateLabel("****", -300, -1)
$my4 = GUICtrlCreateLabel("****", -450, -1)
GUICtrlSetColor($myl, 0xff0000)
GUICtrlSetColor($my2, 0x00FF00)
GUICtrlSetColor($my3, 0xfff000)
GUICtrlSetColor($my4, 0xffffff)
$st = 1
GUISetState()
While GUIGetMsg() <> -3
WEnd

Func _MoveMarquee()
    Local $aCpos1, $aCpos2, $aCpos3, $aCpos4
    Local $stop1, $stop2, $stop3, $stop4 
    $aCpos1 = ControlGetPos($mygui, '', $myl)
    $aCpos2 = ControlGetPos($mygui, '', $my2)
    $aCpos3 = ControlGetPos($mygui, '', $my3)
    $aCpos4 = ControlGetPos($mygui, '', $my4)
    If $aCpos1[0] >= $size and not $stop1 Then 
        setsize1($myl)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10   
        $aCpos1[0] =  -$lenth 
        $stop1 = True
    endif   
    If $aCpos2[0] >= $size and not $stop2 Then 
        setsize2($my2)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10   
        $aCpos2[0] =  -$lenth     
    endif 
    If $aCpos3[0] >= $size and not $stop3 Then 
        setsize3($my3)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10   
        $aCpos3[0] =  -$lenth     
    endif
    If $aCpos4[0] >= $size and not $stop3 Then 
        setsize4($my4)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10   
        $aCpos4[0] =  -$lenth     
    endif   
    ControlMove($mygui, '', $myl, $aCpos1[0] + 1, $aCpos1[1])
    ControlMove($mygui, '', $my2, $aCpos2[0] + 1, $aCpos2[1])
    ControlMove($mygui, '', $my3, $aCpos3[0] + 1, $aCpos3[1])
    ControlMove($mygui, '', $my4, $aCpos4[0] + 1, $aCpos4[1])
EndFunc

func _exit()
exit   
EndFunc

Func setsize1($control, $font = 10)
    ;------------------
    ; -section used for testing
    $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9"
    IniWriteSection(@ScriptDir & "\settings.ini", "users", $sData)
    $inia2= IniReadSection(@ScriptDir & "\settings.ini", "users")
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1]
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data)
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc

Func setsize2($control, $font = 10)
    ;------------------
    ; -section used for testing
   ; $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9"
    ;IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData)
    $inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users")
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1]
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data)
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc

Func setsize3($control, $font = 10)
    ;------------------
    ; -section used for testing
    $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9"
    IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData)
    $inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users")
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1]
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data)
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc

Func setsize4($control, $font = 10)
    ;------------------
    ; -section used for testing
    $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9"
    IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData)
    $inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users")
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1]
    ; -----------------
    GUICtrlSetData( $control, $text)
    $info = ControlGetPos("my gui", "", $control)
    $data = GUICtrlRead($control)
    $lenth = StringLen($data)
    $len =  $lenth * 10
    ControlMove("my gui", "", $control, $info[0], $info[1], $len, $info[3])
EndFunc
Edited by Volly

Share this post


Link to post
Share on other sites

cant you see what i did for the first one

If $aCpos1[0] >= $size and not $stop1 Then

setsize1($myl)

$len = StringLen(GUICtrlRead($myl))

$lenth = $len * 10

$aCpos1[0] = -$lenth

$stop1 = True

endif

and

IniWriteSection(@ScriptDir & "\settings.ini", "users", $sData)

$inia2= IniReadSection(@ScriptDir & "\settings.ini", "users")

not

IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData)

$inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users")

8)

Share this post


Link to post
Share on other sites

ummm...no. sorry, I'm not seeing it. (me > ;) ) I'm really trying however. I changed the code to this, and it made no difference.

If $aCpos2[0] >= $size and not $stop2 Then 
        setsize2($my2)
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10   
        $aCpos2[0] =  -$lenth 
        $stop2 = True
    endif

I commented out the 3rd and 4th boxes so I can keep it simpler while troubleshooting it. The boxes still overlap after the resize.

Share this post


Link to post
Share on other sites

I simplified the script to figure this out. From what I can tell the ControlMove isn't working, no matter what I put in.

#include <GUIConstants.au3>
#Include <Constants.au3>
HotKeySet("^!q", "_exit")
AdlibEnable('_MoveMarquee', 1)
$size = @DesktopWidth +3 
DIM $mygui, $myl, $my2
$mygui = GUICreate('my gui', $size, 18, -1, 0, $WS_POPUP, $WS_EX_TOPMOST)
guisetfont(11.7, 500, 0, "ms comic san",$mygui)
GUISetBkColor ( 0x000000, $mygui )
$myl = GUICtrlCreateLabel("Have a great day!", 0, -2)
$my2 = GUICtrlCreateLabel("****", -50, -1)
GUICtrlSetColor($myl, 0xff0000)
GUICtrlSetColor($my2, 0x00FF00)

GUISetState()
While GUIGetMsg() <> -3
    sleep(1)
WEnd

Func _MoveMarquee()
    Local $aCpos1, $aCpos2, $aCpos3, $aCpos4
    $aCpos1 = ControlGetPos($mygui, '', $myl)
    $aCpos2 = ControlGetPos($mygui, '', $my2)
        if $aCpos1[0] >= $size then  
        setsize1()
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10    
        $aCpos1[0] =  -$lenth     
    Endif  
    If $aCpos2[0] >= $size Then          
        $len = StringLen(GUICtrlRead($myl))
        $lenth = $len * 10    
        $aCpos2[0] =  -$lenth  
        setsize2($my2)
    endif 
    ControlMove($mygui, '', $myl, $aCpos1[0] + 1, $aCpos1[1])
    ControlMove($mygui, '', $my2, $aCpos2[0] + 1, $aCpos2[1])
    EndFunc

func _exit()
exit    
EndFunc

Func setsize1($font = 10)
    ;------------------
    ; -section used for testing
    $sData = "user1 = 7" & @LF & "user2 = 8" & @LF & "user3 = 9"& @LF & "user4 = 8" & @LF & "user = 9" 
    IniWriteSection(@ScriptDir&"/bin/settings.ini", "users", $sData) 
    $inia2= IniReadSection(@ScriptDir&"/bin/settings.ini", "users") 
    $text = "Theresa - "&$inia2[1][1] &"   Charles - "&$inia2[2][1]&"    Tammy - "&$inia2[3][1]&"    John - "&$inia2[4][1]&"    Andrew - "&$inia2[5][1] 
    ; -----------------
    $data_old1 = GUICtrlRead($myl)
    $lenth_old1 = StringLen($data_old1) 
    $len_old1 =  $lenth_old1 * 10   
    GUICtrlSetData($myl, $text)
    $info1 = ControlGetPos("my gui", "", $myl)
    $data1 = GUICtrlRead($myl)
    $lenth1 = StringLen($data1) 
    $len1 =  $lenth1 * 10
    ControlMove("my gui", "", $myl, $info1[0], $info1[1], $len1, $info1[3])
EndFunc

Func setsize2($font = 10)
    $data_old2 = GUICtrlRead($my2)
    $lenth_old2 = StringLen($data_old2) 
    $len_old2 =  $lenth_old2 * 10
    $info_old2 = ControlGetPos("my gui", "", $my2)
    GUICtrlSetData( $my2, "Some text to test to see if it worked")
    $info2 = ControlGetPos("my gui", "", $my2)
    $data2 = GUICtrlRead($my2)
    $lenth2 = StringLen($data2) 
    $len2 =  $lenth2 * 10
    ControlMove("my gui", "", $my2, $info2[0]-($info2[0]+900), $info2[1], $len2, $info2[3])
    ;$info2[0]-($info2[0]+900) gives me a value of -900, which should move the second box. It doesn't???
EndFunc

Share this post


Link to post
Share on other sites

In testing, I noticed I can't change the position of the control in Func setsize2($font = 10) even when I do it like this: ControlMove('my gui',"", $my2, -500, -1)

That command will work if I put it at the top of the script before Func _MoveMarquee() runs for the first time however. ;)

edit: I did notice it will resize the control, however, it will not move it right or left as needed if I put the ControlMove in the function. It will only move if I have it before it first creates it.

Edited by Volly

Share this post


Link to post
Share on other sites

If I were implementing a marquee, I'd try leaving the control in one place and adjusting the text to provide the marquee effect.

Share this post


Link to post
Share on other sites

I plan to have it so the marquee can be changed on the fly, and be controled by a GUI that writes both to it and an excel spreadsheet. (Per clien't request) The marquee will be used on 6 computers that are part of a call center. The client wants to have it so there is real time reporting to the call center operators. The reason for 4 controls is I need to be able to change the color of the text. (also a requirement)

I tried playing with it some more, but I can't get past this one.

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  

×
×
  • Create New...