Jump to content

Repeated scrolling label...


sshrum
 Share

Recommended Posts

Yeah, another media player...but for touchscreens so LARGE BUTTONS! :)

Anywho, I'd like to scroll the "artist - album - title" from right to left in a label and have it repeat again and again while the song is playing.

Anyone have any ideas how to accomplish this easily?

I'm thinking of stringsplit() on all chars and changing the label data starting at +=1 but that seems overkill.

TIA

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

#Include <GuiConstants.au3>
$Gui = GuiCreate("Test", 400,100)
$Label = GuiCtrlCreateLabel("Scroll!", 0,0,100,100)
GuiSetState(@SW_SHOW)

While 1
    For $x = 400 to -100 step -2
       ControlMove ($GUI,"",$Label, $x, 0)
       Sleep(35)
    Next
WEnd

Try that...

Adjusting the sleep and the step alter the speed.

Edited by Paulie
Link to comment
Share on other sites

The problem with that is that the "Scroll!" doesn't repeat...it's solo.

I'm thinking like" Scroll! - Scroll! - Scroll! - Scroll! - Scroll! - Scroll! - Scroll! - Scroll! - "...see what I mean :)

I guess I could make a uberlong label and set the text to be repeated like 10 times (enough that it would take like 5 minutes to completely scroll and then repeat.

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Link to comment
Share on other sites

Oh i see, You don't want the label to move, just the text on it?

Hmm, this kills the reaction time on the GUI, but it works pretty well i guess...

#Include <GuiConstants.au3>
$Gui = GuiCreate("Test", 200,60)
$Label = GuiCtrlCreateLabel("Artist - Album - Title        ", 0,15,200,30)
GUICtrlSetFont(-1, 14, 500,0,"Arial")
GuiSetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    If $Msg = $GUI_EVENT_CLOSE Then Exit
    ScrollText($Label)
WEnd

Func ScrollText($CtrlID,$Step=1)
    $Data = GUICtrlRead($CtrlID)
    $String = StringSplit($Data,"")
    $Firstchars = ""
    For $i = 1 to $Step
        $Firstchars&=$String[$i]
    Next    
    $NewString = StringTrimLeft($Data,$Step) & $Firstchars
    GUICtrlSetData($CtrlID,$NewString)
    Sleep(100)
EndFunc

It might be worth it to "AdLibEnable" the scrolltext function, It may improve reaction time...

Link to comment
Share on other sites

Hi, boredom made me do it :)

#Include <GuiConstants.au3>
Global $lx = 350, $bx = 100, $AdState
Global $Speed = 10  ; lower is faster
Global $Step = 2 ; amount of pixels to move the control each step

$Gui = GuiCreate("Loop Scroll Controls.. bahahaha", 350, 60)
$Label = GuiCtrlCreateLabel("Scroll!", $lx, 0, 34, 20)
$Button = GUICtrlCreateButton("Start Scrolling", $bx, 30, 150, 20)
GuiSetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            If $AdState = 1 Then AdlibDisable()
            Exit
        Case $msg = $Button
            If GUICtrlRead($Button) = "Start Scrolling" Then
                GUICtrlSetData($Button, "Stop Scrolling")
                AdlibEnable("Scroll", $Speed)
                $AdState = 1
            ElseIf GUICtrlRead($Button) = "Stop Scrolling" Then
                GUICtrlSetData($Button, "Start Scrolling")
                AdlibDisable()
                $AdState = 0
            EndIf   
    EndSelect
WEnd

Func Scroll()
    $lx-= $Step
    ControlMove ($GUI,"",$Label, $lx, 0)
    If $lx = -34 Then $lx= 350
    $bx += $Step
    ControlMove ($GUI,"",$Button, $bx , 30)
    If $bx = 350 Then $bx = -150
EndFunc

Cheers

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...