Jump to content

Scrolling title


Recommended Posts

Hello, I have been trying to make a udf for scrolling title text it works if you use on event mode for your gui but in a msg loop unless u click the button before the func starts again it doesn't work. It would be great if someone could help me with this.

heres the code:

#include <String.au3>

GUICreate ("Test",200,100)
$close = GUICtrlCreateButton ("Close",80,60,40,30)
GUISetState ()

While 1
$msg = GUIGetMsg()
Switch $msg 
    Case $close
        Exit
EndSwitch
ScrollingTitle("Test",200) ;call func in the loop so it keeps scrolling
Sleep (10) ;if the sleep time is to big it wont scroll properly
WEnd

Func ScrollingTitle ($title,$width,$s_time = 100)
$nwidth = Int ($width/5)
For $i = 1 To $nwidth
WinSetTitle (_StringRepeat (" ",$i-1) & $title,"",_StringRepeat (" ",$i) & $title)
Sleep ($s_time)
Next
WinSetTitle (_StringRepeat (" ",$nwidth) & $title,"",$title)
EndFunc

Thanks in advance

Link to comment
Share on other sites

Like this:

GUICreate ("Test",200,100)
$close = GUICtrlCreateButton ("Close",80,60,40,30)
GUISetState ()

Global $title = "Test"
Global $width = 200
Global $nwidth = Int ($width/5)
Global $i_TitleCounter = 1
Dim $i_TitleTimeStamp = TimerInit()
Dim $i_time = 100;Time in milliseconds before the title scrolls over an aditional letter

While 1
$msg = GUIGetMsg()
Switch $msg
    Case $close
        Exit
EndSwitch
If TimerDiff($i_TitleTimeStamp) >= $i_time Then
    ScrollTitle()
    $i_TitleTimeStamp = TimerInit()
EndIf
WEnd

Func ScrollTitle()
    If $i_TitleCounter <= $nwidth Then
        WinSetTitle (_StringRepeat (" ",$i_TitleCounter-1) & $title,"",_StringRepeat (" ",$i_TitleCounter) & $title)
        $i_TitleCounter+=1
    Elseif $i_TitleCounter > $nwidth Then
        WinSetTitle (_StringRepeat (" ",$nwidth) & $title,"",$title)
        $i_TitleCounter = 1
    Else
        Msgbox(0,"Error","An error has occured.")
    EndIf
EndFunc

- The Kandie Man ;-)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

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...