Jump to content
Sign in to follow this  

Make Text Scroll to the Left if Longer Than GUI Box

Recommended Posts

I'm making a simple GUI that will stay on top of all my other windows that will work with the Billy MP3 Player.

Basically it's just going to have play/pause, next track, previous track, and a focus button (to bring billy to the front).

But I also want it to display the current song, but some of the song titles are longer than the GUI that I'm making. Is there a way to have the text scroll left/right like it does on players like iTunes when the text is too long to display in the window?

Share this post

Link to post
Share on other sites

Something like this works, but it's a little glitchy. and the function prettymuch kills response time...

#include <GUIConstants.au3>

$LabelText = "This is a really long text line that doesn't fit within the window."
$GUI = GUICreate("ScrollTest", 200, 200)
$Label = GUICtrlCreateLabel($LabelText, 0, 0)
$Button = GUICtrlCreateButton("Response Check", 50, 80, 100, 40)
GUICtrlSetOnEvent(-1, "Response")

While 1
    ScrollLabel($Label,$Gui) ;Left
    ;ScrollLabel($Label,$Gui,"",1) Right

Func Quit()

Func Response()
    MsgBox(0,"", "A Response!")

Func ScrollLabel($Ctrl, $Window, $Text="",  $Direction=0, $Speed=5, $Delay=100)
    $Temp = ControlGetPos($Window,$Text, $Ctrl)
    $Temp2 = WinGetPos($Window, $Text)
    If @error Then
        Return 0
    $cX = $Temp[0]
    $cY = $Temp[1]
    $cWidth = $Temp[2]
    $wWidth = $Temp2[2]
    If Not $Direction  Then   ;Left
        ControlMove($Window,$Text, $Ctrl, $cX-$Speed, $cY)
        If $cX-$Speed <= 0-$cWidth Then
            ControlMove($Window, $Text, $Ctrl, $wWidth, $cY)
    Else ;Right
        ControlMove($Window,$Text, $Ctrl, $cX+$Speed, $cY)
        If $cX+$Speed >= $wWidth Then
            ControlMove($Window, $Text, $Ctrl, 0-$cWidth, $cY)

Edit: I Imagine it would work better in GuiOnEventMode

Edit2: It definitely Does.

Edited by Paulie

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...