Sign in to follow this  
Followers 0
ichigo325

Help me with banner

3 posts in this topic

Hi guys, i'm trying to create some gui banner just like NSIS banner plug-in (Link) but my banner more simple than that. But when i try to insert it in my full script, it make my pc not responding or 100% cpu usage.. I want you guys check my script or maybe you can make it even better than this. Thanks

Here is my code:

_Banner(1, Chr(149) & " loading wololo...")
Sleep(3000) ;some other functions
_Banner(1, @CRLF & Chr(149) & " loading wololo again...") ;update the banner with other strings/text
Sleep(3000)
_Banner(2)

Func _Banner($mode, $text = "")
    Local $lGui, $lProgress, $lLabel

    If $mode = 1 Then
        If WinExists("Loading") <> 1 Then
            $lGui = GUICreate("Loading", 280, 50, -1, -1, 0x80000000 + 0x00400000)
            GUISetBkColor(0xffffff, $lGui)
;~          GUICtrlCreatePic($TempDir & "\Skin\Loading-Gradient.jpg", 0, 10, 280, 40)
;~          GUICtrlCreateAvi($TempDir & "\Skin\Loading.avi", -1, 8, 8, 32, 32, 0x04)
            GUICtrlCreateLabel("", 8, 8, 32, 32, 0x12) ;This is for loading.avi animation)
            GUISetState(@SW_SHOW)
        EndIf

        $lLabel = GUICtrlCreateLabel("", 52, 8, 222, 55)
        GUICtrlSetFont(-1, 11.5)
        GUICtrlSetColor(-1, 0x7d7d7d)
        GUICtrlSetBkColor(-1, -2)
        GUICtrlSetData($lLabel, GUICtrlRead($lLabel) & $text)

        While GUIGetMsg() <> -3
            Return 0
        WEnd

    ElseIf $mode = 2 Then
        GUIDelete($lGui)
        Return 0
    EndIf
EndFunc   ;==>_Banner

[size="2"][font="Lucida Sans Unicode"][b][/b][/font][/size]

Share this post


Link to post
Share on other sites



ichigo325,

Welcvome to the AutoIt forum. ;)

You have a problem becasue you have declared the GUI and Label as Local variables - so weach time you end the function, AutoIt loses their ControlIDs. If you declare them as Global variables all is well:

Global $lGui, $lLabel

$sText = Chr(149) & " loading wololo..."
_Banner(1, $sText)
Sleep(3000) ;some other functions

$sText &= @CRLF & Chr(149) & " loading wololo again..." ;update the banner with other strings/text ; <<<<<<< add new lines to text
_Banner(1, $sText)
Sleep(3000)

_Banner(2)

Func _Banner($mode, $text = "")
    Local $lProgress

    If $mode = 1 Then

        If WinExists("Loading") <> 1 Then
            $lGui = GUICreate("Loading", 280, 50, -1, -1, 0x80000000 + 0x00400000)
            GUISetBkColor(0xffffff, $lGui)
;~          GUICtrlCreatePic($TempDir & "\Skin\Loading-Gradient.jpg", 0, 10, 280, 40)
;~          GUICtrlCreateAvi($TempDir & "\Skin\Loading.avi", -1, 8, 8, 32, 32, 0x04)
            GUICtrlCreateLabel("", 8, 8, 32, 32, 0x12) ;This is for loading.avi animation)
            $lLabel = GUICtrlCreateLabel("", 52, 8, 222, 55)  ; <<<<<<<< only cretae label once
                GUICtrlSetFont(-1, 11.5)
                GUICtrlSetColor(-1, 0x7d7d7d)
                GUICtrlSetBkColor(-1, -2)
            GUISetState(@SW_SHOW)
        EndIf

        GUICtrlSetData($lLabel, $sText)

    Else
        GUIDelete($lGui)
    EndIf
EndFunc   ;==>_Banner

I changed a few other things as well - please ask if you do not understand why.

Of interest, if we do get Static variables in the next update cycle, they would be perfect for this. :evil:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Works flawless.. Thanks for your help.. ;)


[size="2"][font="Lucida Sans Unicode"][b][/b][/font][/size]

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  
Followers 0