Melba23

Marquee UDF - BugFix release 6 Nov 2012

40 posts in this topic

#1 ·  Posted (edited)

BugFix version - 6 Nov 12

Fixed:

- The "no border" setting was ignored.

- Colour values recovered from an ini file (and so passed as strings) were not honoured.

Thanks to AUTTRY for pointing them out. :thumbsup:

New UDF and zip below. :)

Previous releases

Spoiler

BugFix version - 30 Aug 12

The UDF was missing a "Local" statement - the code is unchanged, but you got an error if you used Opt("MustDeclareVars", 1). Apologies to everyone and thanks to supersonic who pointed it out.

My original version of this UDF has been around for some time, but now that it has been modified to allow you to alter the marquee appearance and text "on the fly", I am releasing this much modified version. :)

Warning: If you used the old version then there are script-breaking changes!! (but see below for how to deal with them)

The UDF allows you to embed scrolling marquees (ticker-tape messages) into your GUIs. There are 6 functions in the library:

;_GUICtrlMarquee_Init       : Initialises Marquee control
;_GUICtrlMarquee_SetScroll  : Sets movement parameters for Marquee
;_GUICtrlMarquee_SetDisplay : Sets display parameters for Marquee
;_GUICtrlMarquee_Create     : Creates Marquee
;_GUICtrlMarquee_Delete     : Deletes Marquee control
;_GUICtrlMarquee_Reset      : Resets Marquee control to current parameters

- You begin by intialising the UDF using _GUICtrlMarquee_Init - this function returns an index number which you use to refer to that particular marquee when using the other functions. You can have as many marquees as you wish - the index number is there to distinguish between them.

- The GUICtrlMarquee_SetScroll/SetDisplay/Create functions define and create the marquee - as in the earlier UDF version. Note that there are some subtle changes to the way the parameters behave when set to Default/-1, but for the most part they act as before.

- The GUICtrlMarquee_Reset function resets the text of the marquee - as well as implementing any changes to the appearance of the marquee made by further calls to GUICtrlMarquee_SetScroll/SetDisplay since its creation.

- Unsurprisingly, the GUICtrlMarquee_Delete function deletes the marquee.

Here is an example script to show it working:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

#include "Marquee.au3"

Global $aMarquee_Coords[4] = [0, 0, @DesktopWidth, 60]
Global $fMarquee_Pos = "top", $hGUI = 0

; Create an array to hold the marquee indices
Global $aMarquee[8]

; Create GUI to display various marquee styles
GUICreate("Marquee Example 1", 320, 320)

; Initialise and create the marquees
$aMarquee[0] = _GUICtrlMarquee_Init()
_GUICtrlMarquee_Create($aMarquee[0], "Default Marquee Parameters", 10,  10, 300, 20)

$aMarquee[1] = _GUICtrlMarquee_Init()
_GUICtrlMarquee_SetScroll($aMarquee[1], Default, "alternate", "right", 7)
_GUICtrlMarquee_SetDisplay($aMarquee[1], 1, 0xFF0000, 0xFFFF00, 12, "times new roman")
_GUICtrlMarquee_Create($aMarquee[1], "Back And Forth", 10, 45, 300, 20)

$aMarquee[2] = _GUICtrlMarquee_Init()
_GUICtrlMarquee_SetScroll($aMarquee[2], 0, Default, "up", 1)
_GUICtrlMarquee_SetDisplay($aMarquee[2], 2, "green", Default, 18, "comic sans ms")
_GUICtrlMarquee_Create($aMarquee[2], "Up and Up...", 10, 80, 150, 30, "Vertical Scroll Up")

$aMarquee[3] = _GUICtrlMarquee_Init()
_GUICtrlMarquee_SetScroll($aMarquee[3], 0, Default, "down", 1)
_GUICtrlMarquee_SetDisplay($aMarquee[3], 2, "fuchsia", Default, 18, "comic sans ms")
_GUICtrlMarquee_Create($aMarquee[3], "Down We Go", 160, 80, 150, 30, "Vertical Scroll Down")

$aMarquee[4] = _GUICtrlMarquee_Init()
_GUICtrlMarquee_SetScroll($aMarquee[4], 0, Default, "right", Default, 120)
_GUICtrlMarquee_SetDisplay($aMarquee[4], 3, "red", "silver", 12, "arial")
_GUICtrlMarquee_Create($aMarquee[4], "And slowly to the right", 10, 120, 300, 26)

$aMarquee[5] = _GUICtrlMarquee_Init()
_GUICtrlMarquee_SetScroll($aMarquee[5], 1, "slide", Default, 2)
_GUICtrlMarquee_SetDisplay($aMarquee[5], 1, "blue", "cyan", 9, "courier new")
_GUICtrlMarquee_Create($aMarquee[5], " Just the once", 10, 160, 300, 17)

$aMarquee[6] = _GUICtrlMarquee_Init()
_GUICtrlMarquee_SetScroll($aMarquee[6])
_GUICtrlMarquee_SetDisplay($aMarquee[6])
_GUICtrlMarquee_Create($aMarquee[6], "Default Marquee Parameters", 10, 190, 300, 20, "Everything at default")

; Create buttons to demonstrate UDF functions
$cButton_1 = GUICtrlCreateButton("Change top text", 10, 220, 90, 90, $BS_MULTILINE)
$cButton_2 = GUICtrlCreateButton("Delete" & @CRLF & "'Just the once'", 110, 220, 100, 90, $BS_MULTILINE)
$cButton_3 = GUICtrlCreateButton("Change Back & Forth", 220, 220, 90, 90, $BS_MULTILINE)

GUISetState()

; Look for the TaskBar
Find_Taskbar($aMarquee_Coords)
; Create the banner marquee
If @error Then
    MsgBox(0, "Error", "Could not find taskbar")
Else
    Global $sText = "I can be set to either the top or bottom of the display - just click on the tray icon and you can switch me !"
    ; Create ticker
    $hGUI = GUICreate("Marquee Example 2", $aMarquee_Coords[2], $aMarquee_Coords[3], $aMarquee_Coords[0], $aMarquee_Coords[1], $WS_POPUPWINDOW, $WS_EX_TOPMOST)
    $aMarquee[7] = _GUICtrlMarquee_Init()
    _GUICtrlMarquee_SetScroll($aMarquee[7], 0, Default, "left", Default, 50)
    _GUICtrlMarquee_SetDisplay($aMarquee[7], 1, 0xFFFF00, 0x88CCFF, 26, "Comic Sans MS")
    _GUICtrlMarquee_Create($aMarquee[7], $sText, 0, 0, $aMarquee_Coords[2], $aMarquee_Coords[3])

    GUISetState()

EndIf

; Create the tray menu
Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu
Opt("TrayMenuMode", 3)    ; Default tray menu items will not be shown.
; Only add ticker position options if ticker exists
If WinExists($hGUI) Then
    Global $hTray_Top_Item = TrayCreateItem("Top")
    TrayItemSetOnEvent(-1, "On_Place")
    Global $hTray_Bot_Item = TrayCreateItem("Bottom")
    TrayItemSetOnEvent(-1, "On_Place")
    TrayCreateItem("")
EndIf
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "On_Exit")

TraySetState()

; main loop
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton_1
            _GUICtrlMarquee_Reset($aMarquee[0], "New text set at " & @HOUR & ":" & @MIN & ":" & @SEC)
        Case $cButton_2
            GUICtrlSetState($cButton_2, $GUI_DISABLE)
            _GUICtrlMarquee_Delete($aMarquee[5])
        Case $cButton_3
            GUICtrlSetState($cButton_3, $GUI_DISABLE)
            ; Change type of scroll
            _GUICtrlMarquee_SetScroll($aMarquee[1], -1, "scroll", "right", -1)
            ; Change colours and font
            _GUICtrlMarquee_SetDisplay($aMarquee[1], 2, 0x0000FF, 0xCCFFCC, 14, "Courier New")
            ; And redisplay
            _GUICtrlMarquee_Reset($aMarquee[1], "All different now!")
    EndSwitch
WEnd

Func On_Exit()
    Exit
EndFunc

Func On_Place()

    ; Switch ticker position flag
    If $fMarquee_Pos = "top" Then
        $fMarquee_Pos = "bottom"
    Else
        $fMarquee_Pos = "top"
    EndIf
    ; Find taskbar position and move ticker
    Find_Taskbar($aMarquee_Coords)
    WinMove($hGUI, "", $aMarquee_Coords[0], $aMarquee_Coords[1], $aMarquee_Coords[2], $aMarquee_Coords[3])

EndFunc

Func Find_Taskbar(ByRef $aMarquee_Coords)

    ; Find taskbar and get size
    Local $iPrevMode = AutoItSetOption("WinTitleMatchMode", 4)
    Local $aTaskBar_Pos = WinGetPos("[CLASS:Shell_TrayWnd]")
    AutoItSetOption("WinTitleMatchMode", $iPrevMode)

    ; If error in finding taskbar
    If Not IsArray($aTaskBar_Pos) Then Return SetError(1, 0)

    ; Determine position of taskbar
    If $aTaskBar_Pos[1] > 0 Then
        ; Taskbar at BOTTOM so coords of the marquee are
        $aMarquee_Coords[0] = 0
        $aMarquee_Coords[2] = @DesktopWidth
        If $fMarquee_Pos = "top" Then
            $aMarquee_Coords[1] = 0
        Else
            $aMarquee_Coords[1] = @DesktopHeight - $aTaskBar_Pos[3] - 60
        EndIf
    ElseIf $aTaskBar_Pos[0] > 0 Then
        ; Taskbar at RIGHT so coords of the marquee are
        $aMarquee_Coords[0] = 0
        $aMarquee_Coords[2] = @DesktopWidth - $aTaskBar_Pos[2]
        If $fMarquee_Pos = "top" Then
            $aMarquee_Coords[1] = 0
        Else
            $aMarquee_Coords[1] = @DesktopHeight - 60
        EndIf
    ElseIf $aTaskBar_Pos[2] = @DesktopWidth Then
        ; Taskbar at TOP so coords of the marquee are
        $aMarquee_Coords[0] = 0
        $aMarquee_Coords[2] = @DesktopWidth
        If $fMarquee_Pos = "top" Then
            $aMarquee_Coords[1] = $aTaskBar_Pos[3]
        Else
            $aMarquee_Coords[1] = @DesktopHeight - 60
        EndIf
    ElseIf $aTaskBar_Pos[3] = @DesktopHeight Then
        ; Taskbar at LEFT so coords of the marquee are
        $aMarquee_Coords[0] = $aTaskBar_Pos[2]
        $aMarquee_Coords[2] = @DesktopWidth - $aTaskBar_Pos[2]
        If $fMarquee_Pos = "top" Then
            $aMarquee_Coords[1] = 0
        Else
            $aMarquee_Coords[1] = @DesktopHeight - 60
        EndIf
    EndIf

EndFunc

And here is the UDF itself:

#include-once

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7

; #INDEX# =======================================================================================================================
; Title .........: Marquee
; Description ...: This module contains functions to create and manage marquee controls
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
;_GUICtrlMarquee_Init       : Initialises a Marquee control
;_GUICtrlMarquee_SetScroll  : Sets movement parameters for Marquee
;_GUICtrlMarquee_SetDisplay : Sets display parameters for Marquee
;_GUICtrlMarquee_Create     : Creates Marquee
;_GUICtrlMarquee_Delete     : Deletes a marquee control
;_GUICtrlMarquee_Reset      : Resets a marquee control to current parameters
; ===============================================================================================================================

; #INTERNAL_USE_ONLY#============================================================================================================
;================================================================================================================================

; #INCLUDES# ====================================================================================================================

; #GLOBAL VARIABLES# ============================================================================================================
; Array to hold Marquee parameters
Global $aMarquee_Params[1][13] = [[0, 0, 0, "scroll", "left", 6, 85, 0, 0, 0, 12, "Tahoma", ""]]
; [0][0]  = Count               [n][0]  = ControlID
; [0][1]                        [n][1]  = Obj Ref
; [0][2]  = Def loop state      [n][2]  = Loop state
; [0][3]  = Def move state      [n][3]  = Move state
; [0][4]  = Def move dirn       [n][4]  = Move dirn
; [0][5]  = Def scroll speed    [n][5]  = Scroll speed
; [0][6]  = Def delay time      [n][6]  = Delay time
; [0][7]  = Def border state    [n][7]  = Border state
; [0][8]  = Def text colour     [n][8]  = Text colour
; [0][9]  = Def back colour     [n][9]  = Back colour
; [0][10] = Def font family     [n][10] = Font size
; [0][11] = Def font size       [n][11] = Font family
; [0][12]                       [n][12] = Text

; Get system text and background colours
Global $aMarquee_Colours_Ret = DllCall("User32.dll", "int", "GetSysColor", "int", 8)
$aMarquee_Params[0][8] = BitAND(BitShift(String(Binary($aMarquee_Colours_Ret[0])), 8), 0xFFFFFF)
$aMarquee_Colours_Ret = DllCall("User32.dll", "int", "GetSysColor", "int", 5)
$aMarquee_Params[0][9] = BitAND(BitShift(String(Binary($aMarquee_Colours_Ret[0])), 8), 0xFFFFFF)

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_Init
; Description ...: Initialises UDF prior to creating a Marquee control
; Syntax.........: _GUICtrlMarquee_Init()
; Parameters ....: None
; Return values .: Index of marquee to be passed to other _GUICtrlMarquee functions
; Author ........: Melba 23
; Related .......: Other _GUICtrlMarquee functions
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_Init()

    ; Add a new line to the array
    $aMarquee_Params[0][0] += 1
    ReDim $aMarquee_Params[$aMarquee_Params[0][0] + 1][13]
    ; Copy over the default values
    For $i = 2 To 12
        $aMarquee_Params[$aMarquee_Params[0][0]][$i] = $aMarquee_Params[0][$i]
    Next
    ; Return index of marquee in array
    Return $aMarquee_Params[0][0]

EndFunc   ;==>_GUICtrlMarquee_Init

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_SetScroll
; Description ...: Sets movement parameters for a Marquee
; Syntax.........: _GUICtrlMarquee_SetScroll($iIndex, [$iLoop, [$sMove, [$sDirection, [$iScroll, [$iDelay]]]]])
; Parameters ....: $iIndex       - Index of marquee returned by _GUICtrlMarquee_Init
;                  $iLoop        - [optional] Number of loops to repeat. (Default = infinite, -1 = leave unchanged)
;                                      Use "slide" movement to keep text visible after stopping
;                  $sMove        - [optional] Movement of text.  From  "scroll" (Default), "slide" and "alternate". (-1 = leave unchanged)
;                  $sDirection   - [optional] Direction of scrolling.  From "left" (Default), "right", "up" and "down". (-1 = leave unchanged)
;                  $iScroll      - [optional] Distance of each advance - controls speed of scrolling (Default = 6, -1 = leave unchanged)
;                                      Higher numbers increase speed, lower numbers give smoother animation.
;                  $iDelay       - [optional] Time in milliseconds between each advance (Default = 85, -1 = leave unchanged)
;                                      Higher numbers lower speed, lower numbers give smoother animation.
; Return values .: Success - Returns 1
;                  Failure - Returns 0 and sets @error to 1 - @extended set to index of parameter with error
; Author ........: Melba 23
; Related .......: Other _GUICtrlMarquee functions
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_SetScroll($iIndex, $iLoop = Default, $sMove = Default, $sDirection = Default, $iScroll = Default, $iDelay = Default)

    ; Errorcheck and set parameters
    Switch $iIndex
        Case 1 To $aMarquee_Params[0][0]
            $iIndex = Int($iIndex)
        Case Else
            Return SetError(1, 1, 0)
    EndSwitch

    Switch $iLoop
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][2] = $aMarquee_Params[0][2]
        Case Else
            If IsNumber($iLoop) Then
                $aMarquee_Params[$iIndex][2] = Int(Abs($iLoop))
            Else
                Return SetError(1, 2, 0)
            EndIf
    EndSwitch

    Switch $sMove
        Case -1
            ; No change
        Case "scroll", 'alternate', 'slide'
            $aMarquee_Params[$iIndex][3] = $sMove
        Case Default
            $aMarquee_Params[$iIndex][3] = $aMarquee_Params[0][3]
        Case Else
            Return SetError(1, 3, 0)
    EndSwitch

    Switch $sDirection
        Case -1
            ; No change
        Case 'left', 'right', 'up', 'down'
            $aMarquee_Params[$iIndex][4] = $sDirection
        Case Default
            $aMarquee_Params[$iIndex][4] = $aMarquee_Params[0][4]
        Case Else
            Return SetError(1, 4, 0)
    EndSwitch

    Switch $iScroll
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][5] = $aMarquee_Params[0][5]
        Case Else
            If IsNumber($iScroll) Then
                $aMarquee_Params[$iIndex][5] = Int(Abs($iScroll))
            Else
                Return SetError(1, 5, 0)
            EndIf
    EndSwitch

    Switch $iDelay
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][6] = $aMarquee_Params[0][6]
        Case Else
            If IsNumber($iDelay) Then
                $aMarquee_Params[$iIndex][6] = Int(Abs($iDelay))
            Else
                Return SetError(1, 6, 0)
            EndIf
    EndSwitch

    Return 1

EndFunc   ;==>_GUICtrlMarquee_SetScroll

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_SetDisplay
; Description ...: Sets display parameters for subsequent _GUICtrlCreateMarquee calls
; Syntax.........: _GUICtrlMarquee_SetDisplay($iIndex, [$iBorder, [$vTxtCol, [$vBkCol, [$iPoint, [$sFont]]]])
; Parameters ....: $iIndex  - Index of marquee returned by _GUICtrlMarquee_Init
;                  $iBorder - [optional] 0 = None (Default), 1 = 1 pixel, 2 = 2 pixel, 3 = 3 pixel (-1 = no change)
;                  $vTxtCol - [optional] Colour for text (Default = system colour, -1 = no change)
;                  $vBkCol  - [optional] Colour for Marquee (Default = system colour, -1 = no change)
;                             Colour can be passed as RGB value or as one of the following strings:
;                                'black', 'gray', 'white', 'silver', 'maroon', 'red', 'purple', 'fuchsia',
;                                'green', 'lime', 'olive', 'yellow', 'navy', 'blue', 'teal', 'aqua'
;                  $iPoint  - [optional] Font size (Default = 12, -1 = unchanged)
;                  $sFont   - [optional] Font to use (Default = Tahoma, "" = unchanged)
; Return values .: Success - Returns 0
;                  Failure - Returns 0 and sets @error to 1 - @extended set to index of parameter with error
; Author ........: Melba 23
; Related .......: Other _GUICtrlMarquee functions
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_SetDisplay($iIndex, $iBorder = Default, $vTxtCol = Default, $vBkCol = Default, $iPoint = Default, $sFont = Default)

    ; Errorcheck and set parameters
    Switch $iIndex
        Case 1 To $aMarquee_Params[0][0]
            $iIndex = Int($iIndex)
        Case Else
            Return SetError(1, 1, 0)
    EndSwitch

    Switch $iBorder
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][7] = $aMarquee_Params[0][7]
        Case 0 To 3
            $aMarquee_Params[$iIndex][7] = Int($iBorder)
        Case Else
            Return SetError(1, 2, 0)
    EndSwitch

    Switch $vTxtCol
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][8] = $aMarquee_Params[0][8]
        Case Else
            If Number($vTxtCol) Then
                $aMarquee_Params[$iIndex][8] = Int(Number($vTxtCol))
            Else
                $aMarquee_Params[$iIndex][8] = $vTxtCol
            EndIf
    EndSwitch

    Switch $vBkCol
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][9] = $aMarquee_Params[0][9]
        Case Else
            If Number($vBkCol) Then
                $aMarquee_Params[$iIndex][9] = Int(Number($vBkCol))
            Else
                $aMarquee_Params[$iIndex][9] = $vBkCol
            EndIf
    EndSwitch

    Switch $iPoint
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][10] = $aMarquee_Params[0][10]
        Case Else
            If IsNumber($iPoint) Then
                $aMarquee_Params[$iIndex][10] = Int(Abs($iPoint / .75))
            Else
                Return SetError(1, 5, 0)
            EndIf
    EndSwitch

    Switch $sFont
        Case ""
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][11] = $aMarquee_Params[0][11]
        Case Else
            If IsString($sFont) Then
                $aMarquee_Params[$iIndex][11] = $sFont
            Else
                Return SetError(1, 5, 0)
            EndIf
    EndSwitch

    Return 1

EndFunc   ;==>_GUICtrlMarquee_SetDisplay

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_Create
; Description ...: Creates a marquee control
; Syntax.........: _GUICtrlMarquee_Create($iIndex, $sText, $iLeft, $iTop, $iWidth, $iHeight, [$sTipText])
; Parameters ....: $iIndex  - Index of marquee returned by _GUICtrlMarquee_Init
;                  $sText   - The text (or HTML markup) the marquee should display.
;                  $iLeft   - The left side of the control.
;                  $iTop    - The top of the control.
;                  $iWidth  - The width of the control.
;                  $iHeight - The height of the control.
;                  $sTipTxt - [optional] Tip text displayed when mouse hovers over the control.
; Return values .: Success - Returns 1
;                  Failure - Returns 0 and sets @error as follows
;                                    1 = Invalid index
;                                    2 = Index already used
;                                    3 = Failed to create object
;                                    4 = Failed to embed object
; Author ........: james3mg, trancexx and jscript "FROM BRAZIL"
; Modified.......: Melba23
; Remarks .......: This function attempts to embed an 'ActiveX Control' or a 'Document Object' inside the GUI.
;                  The GUI functions GUICtrlRead and GUICtrlSet have no effect on this control. The object can only be
;                  controlled using other _GUICtrlMarquee functions
; Related .......: Other _GUICtrlMarquee functions
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_Create($iIndex, $sText, $iLeft, $iTop, $iWidth, $iHeight, $sTipText = "")

    ; Errorcheck index
    Switch $iIndex
        Case 1 To $aMarquee_Params[0][0]
            $iIndex = Int($iIndex)
        Case Else
            Return SetError(1, 0, 0)
    EndSwitch

    ; Check not previously created
    If $aMarquee_Params[$iIndex][1] <> "" Then
        Return SetError(2, 0, 0)
    EndIf

    ; Store text
    $aMarquee_Params[$iIndex][12] = $sText

    ; Create marquee
    Local $oShell = ObjCreate("Shell.Explorer.2")
    If Not IsObj($oShell) Then
        Return SetError(3, 0, 0)
    Else
        $aMarquee_Params[$iIndex][1] = $oShell
    EndIf
    $aMarquee_Params[$iIndex][0] = GUICtrlCreateObj($oShell, $iLeft, $iTop, $iWidth, $iHeight)
    If $aMarquee_Params[$iIndex][0] = 0 Then
        Return SetError(4, 0, 0)
    EndIf

    ; Wait for marquee to be created
    $oShell.navigate("about:blank")
    While $oShell.busy
        Sleep(100)
    WEnd

    ; Add marquee content
    With $oShell.document
        .write('<style>marquee{cursor: default}></style>')
        .write('<body onselectstart="return false" oncontextmenu="return false" onclick="return false" ondragstart="return false" ondragover="return false">')
        .writeln('<marquee width=100% height=100%')
        .writeln("loop=" & $aMarquee_Params[$iIndex][2])
        .writeln("behavior=" & $aMarquee_Params[$iIndex][3])
        .writeln("direction=" & $aMarquee_Params[$iIndex][4])
        .writeln("scrollamount=" & $aMarquee_Params[$iIndex][5])
        .writeln("scrolldelay=" & $aMarquee_Params[$iIndex][6])
        .write(">")
        .write($sText)
        .body.title = $sTipText
        .body.topmargin = 0
        .body.leftmargin = 0
        .body.scroll = "no"
        .body.style.borderWidth = $aMarquee_Params[$iIndex][7]
        .body.style.color = $aMarquee_Params[$iIndex][8]
        .body.bgcolor = $aMarquee_Params[$iIndex][9]
        .body.style.fontSize = $aMarquee_Params[$iIndex][10]
        .body.style.fontFamily = $aMarquee_Params[$iIndex][11]
    EndWith

    Return 1

EndFunc   ;==>_GUICtrlMarquee_Create

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_Delete
; Description ...: Deletes a marquee control
; Syntax.........: _GUICtrlMarquee_Delete($iIndex)
; Parameters ....: $iIndex - Index of marquee returned by _GUICtrlMarquee_Init
; Return values .: Success - Returns 1
;                  Failure - Returns 0 and sets @error to 1
; Author ........: Melba23
; Remarks .......:
; Related .......: Other _GUICtrlMarquee functions
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_Delete($iIndex)

    ; Errorcheck index
    Switch $iIndex
        Case 1 To $aMarquee_Params[0][0]
            $iIndex = Int($iIndex)
        Case Else
            Return SetError(1, 0, 0)
    EndSwitch

    ; Remove that entry from the array
    GUICtrlDelete($aMarquee_Params[$iIndex][0])
    For $i = $iIndex To $aMarquee_Params[0][0] - 1
        For $j = 0 To UBound($aMarquee_Params, 2) - 1
            $aMarquee_Params[$i][$j] = $aMarquee_Params[$i + 1][$j]
        Next
    Next
    ReDim $aMarquee_Params[$aMarquee_Params[0][0]][13]
    $aMarquee_Params[0][0] -= 1

    ; Redraw the other marquees
    For $i = 1 To $aMarquee_Params[0][0]
        _GUICtrlMarquee_Reset($i)
    Next

EndFunc   ;==>_GUICtrlMarquee_Delete

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_Reset
; Description ...: Resets a marquee control to current parameters
; Syntax.........: _GUICtrlMarquee_Reset($iIndex, $sText)
; Parameters ....: $iIndex - Index of marquee returned by _GUICtrlMarquee_Init
;                  $sText  - The text (or HTML markup) the marquee should display (Default leaves text unchanged)
; Return values .: Success - Returns 1
;                  Failure - Returns 0 and sets @error as follows
;                                    1 = Invalid index
;                                    2 = Invalid object reference
; Author ........: rover
; Modified.......: Melba23
; Remarks .......:
; Related .......: Other _GUICtrlMarquee functions
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_Reset($iIndex, $sText = Default)

    ; Errorcheck index
    Switch $iIndex
        Case 1 To $aMarquee_Params[0][0]
            $iIndex = Int($iIndex)
        Case Else
            Return SetError(1, 0, 0)
    EndSwitch

    ; Retrieve object reference
    Local $oShell = $aMarquee_Params[$iIndex][1]
    If Not IsObj($oShell) Then
        Return SetError(2, 0, 0)
    EndIf

    If $sText <> Default Then
        $aMarquee_Params[$iIndex][12] = $sText
    EndIf

    $oShell.document.body.innerHTML = '<body onselectstart="return false" oncontextmenu="return false" onclick="return false" ' & _
        'ondragstart="return false" ondragover="return false"> ' & _
        '<marquee width=100% height=100% ' & "loop=" & $aMarquee_Params[$iIndex][2] & _
        " behavior=" & $aMarquee_Params[$iIndex][3] & _
        " direction=" & $aMarquee_Params[$iIndex][4] & _
        " scrollamount=" & $aMarquee_Params[$iIndex][5] & _
        " scrolldelay=" & $aMarquee_Params[$iIndex][6] & _
        ">" & $aMarquee_Params[$iIndex][12]
    With $oShell.document
        .body.style.borderWidth = $aMarquee_Params[$iIndex][7]
        .body.style.color = $aMarquee_Params[$iIndex][8]
        .body.bgcolor = $aMarquee_Params[$iIndex][9]
        .body.style.fontSize = $aMarquee_Params[$iIndex][10]
        .body.style.fontFamily = $aMarquee_Params[$iIndex][11]
    EndWith

    Return 1

EndFunc   ;==>_GUICtrlMarquee_SetText

And here are the 2 files in zip format: Marquee.zip

As always, ready for compliments and/or complaints! :D

M23

P.S. How to modify your existing marquee scripts:

Spoiler

If you were using the original version of the UDF here is how to change your code so that it works with the new version:

- 1. You need to add a _GUICtrlmarquee_Init line before you do anything with the marquee and store the return value (the index number of the marquee).

- 2. You need to use that index number as the first parameter for all the other _GUICtrlMarquee_* functions.

- 3. You delete the marquee by replacing the GUICtrlDelete($cCID) line (where $cCID was the return from _GUICtrlMarquee_Create) with _GUICtrlMarquee_Delete($iIndex) (where $iIndex is the return from _GUICtrlMarquee_Init.

So

; Creation
_GUICtrlMarquee_SetScroll(0, "scroll", "left", 4, 100)
_GUICtrlMarquee_SetDisplay(0, -1, -1, 12, "Arial")
$cMarquee = _GUICtrlMarquee_Create($sText, 5, 5, 185, 50)

; Deletion
GUICtrlDelete($cMarquee)

becomes

; Creation
$cMarquee = _GUICtrlMarquee_Init()
_GUICtrlMarquee_SetScroll($cMarquee, 0, "scroll", "left", 4, 100)
_GUICtrlMarquee_SetDisplay($cMarquee, 0, -1, -1, 12, "Arial")
_GUICtrlMarquee_Create($cMarquee, $sText, 5, 5, 185, 50)

; Deletion
_GUICtrlMarquee_Delete($cMarquee)

I hope you will agree that the ability to change the marquee "on the fly" is worth these small changes you will have to make to any scripts that use marquee controls.

Edited by Melba23
2 people like this

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



This looks a pretty good customizable version of and the example made my eyes to see crossed. muttley

Thanks for share!


When the words fail... music speaks

Share this post


Link to post
Share on other sites

I got the topic notification as RSS feed, and i had difficulties to click the topic link, guess why?

That's right, the text constantly moving in the feed :D

Nice UDF.


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Andreik,

You are quite correct - as acknowledged in the UDF: ;)

Name...........: _GUICtrlMarquee_Create

; Author ........: james3mg, trancexx and jscript "FROM BRAZIL"
; Modified.......: Melba23

czardas,

Glad it made you smile! :D

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

#7 ·  Posted (edited)

Melba23,

this is fun - thank you! :)

I got an error if using the option "MustDeclareVars" - changed line 313 to:

Local $oShell = ObjCreate("Shell.Explorer.2")

solved it.

Greets,

-supersonic.

Edited by supersonic

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

supersonic,

Oops! :>

Thanks for the report. :thumbsup:

M23

Edit: Modified version now in first post. :)

Edited by Melba23

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

#9 ·  Posted (edited)

Melba23,

I tried the updated UDF and found it more interesting.

But It doesn't work when I called _GUICtrlMarquee_SetDisplay function passing parameter $iBorder = 0.

To make it work, I just simply changed line 205 to:

Case 0 To 3

Besides, if the text color and/or the background color are read from an INI file, I have to convert it to a Number before calling _GUICtrlMarquee_SetDisplay function to avoid the error when setting html document properties in _GUICtrlMarquee_Create function. The _GUICtrlMarquee_SetDisplay function just can't work as GUICtrlSetColor() or GUISetBkColor() which accepts a color string like "0xFF0000".

Thanks if you can check my concerns above.

Auttry

Edited by AUTTRY

Share this post


Link to post
Share on other sites

AUTTRY,

Thanks for the report - I can see both problems (expecially as you showed me the first! ;)) and I am working on it. Expect a new version later today. :)

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

BugFix version - 6 Nov 12

Fixed:

- The "no border" setting was ignored.

- Colour values recovered from an ini file (and so passed as strings) were not honoured.

Thanks to AUTTRY for pointing them out. :thumbsup:

New UDF and zip in first post. :)

M23

Note: As a numeric value recovered from an ini file is always in string format, it is normally the coder's responsibility to make sure that the value is recast as a number (with the Number function) before using it. Doing so would have prevented the second "bug" from appearing. ;)

However, as the UDF will also accept literal string values (i.e. "red", "green") for the colour value, I felt that is was a good idea to amend the UDF to handle the conversion internally on this occasion. :)


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

Thank u very much.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Good work! So far so good with the latest BugFix version.

I noted that a Marquee occupied much more memory resources (about 10MB) than a Label control. It's not a good thing.

Try this to compare:

#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include "Marquee.au3"

Const $str = "For Marquee memory test."

$hGUI = GUICreate("", 285, 45, -1, -1, -1, $WS_EX_TOPMOST)
GUISetBkColor(0x19619C)

; Marquee
$aMarquee = _GUICtrlMarquee_Init()
_GUICtrlMarquee_SetScroll($aMarquee, Default, "slide", "left", 1, 1)
_GUICtrlMarquee_SetDisplay($aMarquee, 0, 0xF0FC29, 0x19619C, 8.5, "Courier New")
_GUICtrlMarquee_Create($aMarquee, $str, 80, 16, 180, 20)

;Label
;~ $Label = GUICtrlCreateLabel($str, 100, 16, 150, 20, -1)
;~ GUICtrlSetFont(-1, 8.5)
;~ GUICtrlSetColor(-1, 0xF0FC29)

GUISetState()

Do
Until GUIGetMsg() = -3

The memory usage won't go down even after _GUICtrlMarquee_Delete is called.

Edited by AUTTRY

Share this post


Link to post
Share on other sites

AUTTRY,

It is hardly suprising that a marquee uses more memory than a simple label - after all you are creating a Shell.Explorer.2 object each time which is basically a mini browser. Although I get nothing like 10Mb extra usage when I run the 2 versions of your posted script - it is only about 2.4Mb more on my machine. ;)

But you are correct about the retained memory - I was not deleting the object itself when I deleted the entry in the internal array. Try using this amended function in the UDF and see if you get a better result - I drop about 600kb when I delete the marquee now - which reduces the overhead to 1.8Mb on my machine

Func _GUICtrlMarquee_Delete($iIndex)

    ; Errorcheck index
    Switch $iIndex
        Case 1 To $aMarquee_Params[0][0]
            $iIndex = Int($iIndex)
        Case Else
            Return SetError(1, 0, 0)
    EndSwitch

    ; Delete the object
    $aMarquee_Params[$iIndex][1] = 0 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    ; Remove that entry from the array
    GUICtrlDelete($aMarquee_Params[$iIndex][0])
    For $i = $iIndex To $aMarquee_Params[0][0] - 1
        For $j = 0 To UBound($aMarquee_Params, 2) - 1
            $aMarquee_Params[$i][$j] = $aMarquee_Params[$i + 1][$j]
        Next
    Next
    ReDim $aMarquee_Params[$aMarquee_Params[0][0]][13]
    $aMarquee_Params[0][0] -= 1

    ; Redraw the other marquees
    For $i = 1 To $aMarquee_Params[0][0]
        _GUICtrlMarquee_Reset($i)
    Next

EndFunc   ;==>_GUICtrlMarquee_Delete

The additional 1.8Mb memory used seems to remain constant regardless of how many marquees are created and deleted - I amended the script to use several marquees and each added another 600kb to the overall memory usage which was returned when the relevant object was deleted. I imagine that this memory is only released when the script ends and I am afraid I have no idea of how to do anything about that - but I will keep looking. :)

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

Share this post


Link to post
Share on other sites

AUTTRY,,

Try this version of the UDF - I get very similar memory usage between the 2 versions now: :)

#include-once

;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7

; #INDEX# =======================================================================================================================
; Title .........: Marquee
; Description ...: This module contains functions to create and manage marquee controls
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
;_GUICtrlMarquee_Init       : Initialises a Marquee control
;_GUICtrlMarquee_SetScroll  : Sets movement parameters for Marquee
;_GUICtrlMarquee_SetDisplay : Sets display parameters for Marquee
;_GUICtrlMarquee_Create     : Creates Marquee
;_GUICtrlMarquee_Delete     : Deletes a marquee control
;_GUICtrlMarquee_Reset      : Resets a marquee control to current parameters
; ===============================================================================================================================

; #INTERNAL_USE_ONLY#============================================================================================================
;__GUIMarquee_MemReduce()   : Reduce memory usage by Shell.Explorer.2 objects
;================================================================================================================================

; #INCLUDES# ====================================================================================================================

; #GLOBAL VARIABLES# ============================================================================================================
; Array to hold Marquee parameters
Global $aMarquee_Params[1][13] = [[0, 0, 0, "scroll", "left", 6, 85, 0, 0, 0, 12, "Tahoma", ""]]
; [0][0]  = Count                [n][0]  = ControlID
; [0][1]                        [n][1]  = Obj Ref
; [0][2]  = Def loop state        [n][2]  = Loop state
; [0][3]  = Def move state        [n][3]  = Move state
; [0][4]  = Def move dirn        [n][4]  = Move dirn
; [0][5]  = Def scroll speed    [n][5]  = Scroll speed
; [0][6]  = Def delay time        [n][6]  = Delay time
; [0][7]  = Def border state    [n][7]  = Border state
; [0][8]  = Def text colour        [n][8]  = Text colour
; [0][9]  = Def back colour        [n][9]  = Back colour
; [0][10] = Def font family        [n][10] = Font size
; [0][11] = Def font size        [n][11] = Font family
; [0][12]                        [n][12] = Text

; Get system text and background colours
Global $aMarquee_Colours_Ret = DllCall("User32.dll", "int", "GetSysColor", "int", 8)
$aMarquee_Params[0][8] = BitAND(BitShift(String(Binary($aMarquee_Colours_Ret[0])), 8), 0xFFFFFF)
$aMarquee_Colours_Ret = DllCall("User32.dll", "int", "GetSysColor", "int", 5)
$aMarquee_Params[0][9] = BitAND(BitShift(String(Binary($aMarquee_Colours_Ret[0])), 8), 0xFFFFFF)

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_Init
; Description ...: Initialises UDF prior to creating a Marquee control
; Syntax.........: _GUICtrlMarquee_Init()
; Parameters ....: None
; Return values .: Index of marquee to be passed to other _GUICtrlMarquee functions
; Author ........: Melba 23
; Related .......: Other _GUICtrlMarquee functions
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_Init()

    ; Add a new line to the array
    $aMarquee_Params[0][0] += 1
    ReDim $aMarquee_Params[$aMarquee_Params[0][0] + 1][13]
    ; Copy over the default values
    For $i = 2 To 12
        $aMarquee_Params[$aMarquee_Params[0][0]][$i] = $aMarquee_Params[0][$i]
    Next
    ; Return index of marquee in array
    Return $aMarquee_Params[0][0]

EndFunc   ;==>_GUICtrlMarquee_Init

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_SetScroll
; Description ...: Sets movement parameters for a Marquee
; Syntax.........: _GUICtrlMarquee_SetScroll($iIndex, [$iLoop, [$sMove, [$sDirection, [$iScroll, [$iDelay]]]]])
; Parameters ....: $iIndex       - Index of marquee returned by _GUICtrlMarquee_Init
;                  $iLoop        - [optional] Number of loops to repeat. (Default = infinite, -1 = leave unchanged)
;                                      Use "slide" movement to keep text visible after stopping
;                  $sMove        - [optional] Movement of text.  From  "scroll" (Default), "slide" and "alternate". (-1 = leave unchanged)
;                  $sDirection   - [optional] Direction of scrolling.  From "left" (Default), "right", "up" and "down". (-1 = leave unchanged)
;                  $iScroll      - [optional] Distance of each advance - controls speed of scrolling (Default = 6, -1 = leave unchanged)
;                                      Higher numbers increase speed, lower numbers give smoother animation.
;                  $iDelay       - [optional] Time in milliseconds between each advance (Default = 85, -1 = leave unchanged)
;                                      Higher numbers lower speed, lower numbers give smoother animation.
; Return values .: Success - Returns 1
;                  Failure - Returns 0 and sets @error to 1 - @extended set to index of parameter with error
; Author ........: Melba 23
; Related .......: Other _GUICtrlMarquee functions
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_SetScroll($iIndex, $iLoop = Default, $sMove = Default, $sDirection = Default, $iScroll = Default, $iDelay = Default)

    ; Errorcheck and set parameters
    Switch $iIndex
        Case 1 To $aMarquee_Params[0][0]
            $iIndex = Int($iIndex)
        Case Else
            Return SetError(1, 1, 0)
    EndSwitch

    Switch $iLoop
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][2] = $aMarquee_Params[0][2]
        Case Else
            If IsNumber($iLoop) Then
                $aMarquee_Params[$iIndex][2] = Int(Abs($iLoop))
            Else
                Return SetError(1, 2, 0)
            EndIf
    EndSwitch

    Switch $sMove
        Case -1
            ; No change
        Case "scroll", 'alternate', 'slide'
            $aMarquee_Params[$iIndex][3] = $sMove
        Case Default
            $aMarquee_Params[$iIndex][3] = $aMarquee_Params[0][3]
        Case Else
            Return SetError(1, 3, 0)
    EndSwitch

    Switch $sDirection
        Case -1
            ; No change
        Case 'left', 'right', 'up', 'down'
            $aMarquee_Params[$iIndex][4] = $sDirection
        Case Default
            $aMarquee_Params[$iIndex][4] = $aMarquee_Params[0][4]
        Case Else
            Return SetError(1, 4, 0)
    EndSwitch

    Switch $iScroll
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][5] = $aMarquee_Params[0][5]
        Case Else
            If IsNumber($iScroll) Then
                $aMarquee_Params[$iIndex][5] = Int(Abs($iScroll))
            Else
                Return SetError(1, 5, 0)
            EndIf
    EndSwitch

    Switch $iDelay
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][6] = $aMarquee_Params[0][6]
        Case Else
            If IsNumber($iDelay) Then
                $aMarquee_Params[$iIndex][6] = Int(Abs($iDelay))
            Else
                Return SetError(1, 6, 0)
            EndIf
    EndSwitch

    Return 1

EndFunc   ;==>_GUICtrlMarquee_SetScroll

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_SetDisplay
; Description ...: Sets display parameters for subsequent _GUICtrlCreateMarquee calls
; Syntax.........: _GUICtrlMarquee_SetDisplay($iIndex, [$iBorder, [$vTxtCol, [$vBkCol, [$iPoint, [$sFont]]]])
; Parameters ....: $iIndex  - Index of marquee returned by _GUICtrlMarquee_Init
;                  $iBorder - [optional] 0 = None (Default), 1 = 1 pixel, 2 = 2 pixel, 3 = 3 pixel (-1 = no change)
;                  $vTxtCol - [optional] Colour for text (Default = system colour, -1 = no change)
;                  $vBkCol  - [optional] Colour for Marquee (Default = system colour, -1 = no change)
;                             Colour can be passed as RGB value or as one of the following strings:
;                                'black', 'gray', 'white', 'silver', 'maroon', 'red', 'purple', 'fuchsia',
;                                'green', 'lime', 'olive', 'yellow', 'navy', 'blue', 'teal', 'aqua'
;                  $iPoint  - [optional] Font size (Default = 12, -1 = unchanged)
;                  $sFont   - [optional] Font to use (Default = Tahoma, "" = unchanged)
; Return values .: Success - Returns 0
;                  Failure - Returns 0 and sets @error to 1 - @extended set to index of parameter with error
; Author ........: Melba 23
; Related .......: Other _GUICtrlMarquee functions
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_SetDisplay($iIndex, $iBorder = Default, $vTxtCol = Default, $vBkCol = Default, $iPoint = Default, $sFont = Default)

    ; Errorcheck and set parameters
    Switch $iIndex
        Case 1 To $aMarquee_Params[0][0]
            $iIndex = Int($iIndex)
        Case Else
            Return SetError(1, 1, 0)
    EndSwitch

    Switch $iBorder
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][7] = $aMarquee_Params[0][7]
        Case 0 To 3
            $aMarquee_Params[$iIndex][7] = Int($iBorder)
        Case Else
            Return SetError(1, 2, 0)
    EndSwitch

    Switch $vTxtCol
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][8] = $aMarquee_Params[0][8]
        Case Else
            If Number($vTxtCol) Then
                $aMarquee_Params[$iIndex][8] = Int(Number($vTxtCol))
            Else
                $aMarquee_Params[$iIndex][8] = $vTxtCol
            EndIf
    EndSwitch

    Switch $vBkCol
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][9] = $aMarquee_Params[0][9]
        Case Else
            If Number($vBkCol) Then
                $aMarquee_Params[$iIndex][9] = Int(Number($vBkCol))
            Else
                $aMarquee_Params[$iIndex][9] = $vBkCol
            EndIf
    EndSwitch

    Switch $iPoint
        Case -1
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][10] = $aMarquee_Params[0][10]
        Case Else
            If IsNumber($iPoint) Then
                $aMarquee_Params[$iIndex][10] = Int(Abs($iPoint / .75))
            Else
                Return SetError(1, 5, 0)
            EndIf
    EndSwitch

    Switch $sFont
        Case ""
            ; No change
        Case Default
            $aMarquee_Params[$iIndex][11] = $aMarquee_Params[0][11]
        Case Else
            If IsString($sFont) Then
                $aMarquee_Params[$iIndex][11] = $sFont
            Else
                Return SetError(1, 5, 0)
            EndIf
    EndSwitch

    Return 1

EndFunc   ;==>_GUICtrlMarquee_SetDisplay

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_Create
; Description ...: Creates a marquee control
; Syntax.........: _GUICtrlMarquee_Create($iIndex, $sText, $iLeft, $iTop, $iWidth, $iHeight, [$sTipText])
; Parameters ....: $iIndex  - Index of marquee returned by _GUICtrlMarquee_Init
;                  $sText   - The text (or HTML markup) the marquee should display.
;                  $iLeft   - The left side of the control.
;                  $iTop    - The top of the control.
;                  $iWidth  - The width of the control.
;                  $iHeight - The height of the control.
;                  $sTipTxt - [optional] Tip text displayed when mouse hovers over the control.
; Return values .: Success - Returns 1
;                  Failure - Returns 0 and sets @error as follows
;                                    1 = Invalid index
;                                    2 = Index already used
;                                    3 = Failed to create object
;                                    4 = Failed to embed object
; Author ........: james3mg, trancexx and jscript "FROM BRAZIL"
; Modified.......: Melba23
; Remarks .......: This function attempts to embed an 'ActiveX Control' or a 'Document Object' inside the GUI.
;                  The GUI functions GUICtrlRead and GUICtrlSet have no effect on this control. The object can only be
;                  controlled using other _GUICtrlMarquee functions
; Related .......: Other _GUICtrlMarquee functions
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_Create($iIndex, $sText, $iLeft, $iTop, $iWidth, $iHeight, $sTipText = "")

    ; Errorcheck index
    Switch $iIndex
        Case 1 To $aMarquee_Params[0][0]
            $iIndex = Int($iIndex)
        Case Else
            Return SetError(1, 0, 0)
    EndSwitch

    ; Check not previously created
    If $aMarquee_Params[$iIndex][1] <> "" Then
        Return SetError(2, 0, 0)
    EndIf

    ; Store text
    $aMarquee_Params[$iIndex][12] = $sText

    ; Create marquee
    Local $oShell = ObjCreate("Shell.Explorer.2")
    If Not IsObj($oShell) Then
        Return SetError(3, 0, 0)
    Else
        $aMarquee_Params[$iIndex][1] = $oShell
    EndIf
    $aMarquee_Params[$iIndex][0] = GUICtrlCreateObj($oShell, $iLeft, $iTop, $iWidth, $iHeight)
    If $aMarquee_Params[$iIndex][0] = 0 Then
        Return SetError(4, 0, 0)
    EndIf

    ; Wait for marquee to be created
    $oShell.navigate("about:blank")
    While $oShell.busy
        Sleep(100)
    WEnd

    ; Add marquee content
    With $oShell.document
        .write('<style>marquee{cursor: default}></style>')
        .write('<body onselectstart="return false" oncontextmenu="return false" onclick="return false" ondragstart="return false" ondragover="return false">')
        .writeln('<marquee width=100% height=100%')
        .writeln("loop=" & $aMarquee_Params[$iIndex][2])
        .writeln("behavior=" & $aMarquee_Params[$iIndex][3])
        .writeln("direction=" & $aMarquee_Params[$iIndex][4])
        .writeln("scrollamount=" & $aMarquee_Params[$iIndex][5])
        .writeln("scrolldelay=" & $aMarquee_Params[$iIndex][6])
        .write(">")
        .write($sText)
        .body.title = $sTipText
        .body.topmargin = 0
        .body.leftmargin = 0
        .body.scroll = "no"
        .body.style.borderWidth = $aMarquee_Params[$iIndex][7]
        .body.style.color = $aMarquee_Params[$iIndex][8]
        .body.bgcolor = $aMarquee_Params[$iIndex][9]
        .body.style.fontSize = $aMarquee_Params[$iIndex][10]
        .body.style.fontFamily = $aMarquee_Params[$iIndex][11]
    EndWith

    ; Free memory
    __GUIMarquee_MemReduce()

    Return 1

EndFunc   ;==>_GUICtrlMarquee_Create

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_Delete
; Description ...: Deletes a marquee control
; Syntax.........: _GUICtrlMarquee_Delete($iIndex)
; Parameters ....: $iIndex - Index of marquee returned by _GUICtrlMarquee_Init
; Return values .: Success - Returns 1
;                  Failure - Returns 0 and sets @error to 1
; Author ........: Melba23
; Remarks .......:
; Related .......: Other _GUICtrlMarquee functions
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_Delete($iIndex)

    ; Errorcheck index
    Switch $iIndex
        Case 1 To $aMarquee_Params[0][0]
            $iIndex = Int($iIndex)
        Case Else
            Return SetError(1, 0, 0)
    EndSwitch

    ; Delete the object
    $aMarquee_Params[$iIndex][1] = 0
    ; And free the memory
    __GUIMarquee_MemReduce()

    ; Remove that entry from the array
    GUICtrlDelete($aMarquee_Params[$iIndex][0])
    For $i = $iIndex To $aMarquee_Params[0][0] - 1
        For $j = 0 To UBound($aMarquee_Params, 2) - 1
            $aMarquee_Params[$i][$j] = $aMarquee_Params[$i + 1][$j]
        Next
    Next
    ReDim $aMarquee_Params[$aMarquee_Params[0][0]][13]
    $aMarquee_Params[0][0] -= 1

    ; Redraw the other marquees
    For $i = 1 To $aMarquee_Params[0][0]
        _GUICtrlMarquee_Reset($i)
    Next

EndFunc   ;==>_GUICtrlMarquee_Delete

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_Reset
; Description ...: Resets a marquee control to current parameters
; Syntax.........: _GUICtrlMarquee_Reset($iIndex, $sText)
; Parameters ....: $iIndex - Index of marquee returned by _GUICtrlMarquee_Init
;                  $sText  - The text (or HTML markup) the marquee should display (Default leaves text unchanged)
; Return values .: Success - Returns 1
;                  Failure - Returns 0 and sets @error as follows
;                                    1 = Invalid index
;                                    2 = Invalid object reference
; Author ........: rover
; Modified.......: Melba23
; Remarks .......:
; Related .......: Other _GUICtrlMarquee functions
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_Reset($iIndex, $sText = Default)

    ; Errorcheck index
    Switch $iIndex
        Case 1 To $aMarquee_Params[0][0]
            $iIndex = Int($iIndex)
        Case Else
            Return SetError(1, 0, 0)
    EndSwitch

    ; Retrieve object reference
    $oShell = $aMarquee_Params[$iIndex][1]
    If Not IsObj($oShell) Then
        Return SetError(2, 0, 0)
    EndIf

    If $sText <> Default Then
        $aMarquee_Params[$iIndex][12] = $sText
    EndIf

    $oShell.document.body.innerHTML = '<body onselectstart="return false" oncontextmenu="return false" onclick="return false" ' & _
        'ondragstart="return false" ondragover="return false"> ' & _
        '<marquee width=100% height=100% ' & "loop=" & $aMarquee_Params[$iIndex][2] & _
        " behavior=" & $aMarquee_Params[$iIndex][3] & _
        " direction=" & $aMarquee_Params[$iIndex][4] & _
        " scrollamount=" & $aMarquee_Params[$iIndex][5] & _
        " scrolldelay=" & $aMarquee_Params[$iIndex][6] & _
        ">" & $aMarquee_Params[$iIndex][12]
    With $oShell.document
        .body.style.borderWidth = $aMarquee_Params[$iIndex][7]
        .body.style.color = $aMarquee_Params[$iIndex][8]
        .body.bgcolor = $aMarquee_Params[$iIndex][9]
        .body.style.fontSize = $aMarquee_Params[$iIndex][10]
        .body.style.fontFamily = $aMarquee_Params[$iIndex][11]
    EndWith

    Return 1

EndFunc   ;==>_GUICtrlMarquee_SetText

; #INTERNAL USE ONLY# ====================================================================================================================
; Name...........: _GUICtrlMarquee_MemReduce
; Description ...: Reduce memory usage by Shell.Explorer.2 objects
; Syntax.........: _GUICtrlMarquee_MemReduce()
; Author ........: AutoUt forum
; Remarks .......: This function is used internally by
; ===============================================================================================================================

Func __GUIMarquee_MemReduce()
    Local $aHandle = DllCall("kernel32.dll", "int", "OpenProcess", "int", 0x1f0fff, "int", 0, "int", @AutoItPID)
    DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", $aHandle[0])
    DllCall("kernel32.dll", "int", "CloseHandle", "int", $aHandle[0])
EndFunc

How do you get on? :huh:

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

#17 ·  Posted (edited)

@Melba

I think it would better if you used the following function:

BOOL WINAPI SetProcessWorkingSetSize(
  _In_  HANDLE hProcess,
  _In_  SIZE_T dwMinimumWorkingSetSize,
  _In_  SIZE_T dwMaximumWorkingSetSize
);

In any case, the changes were very good, thank you!

JS

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites

JScript,

From what I have read about this looking for a solution you would need to set the Min/Max parameters to (SIZE_T)-1 in that snippet - and in any event it is functionally equivalent to the EmptyWorkingSet solution. Or do you have more information about all this than is available on MSDN? :huh:

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

Doesn't your MemReduce function just page the memory used to the hard drive, thus making things slower? Also, doesn't this just fool the user into thinking the memory used is less?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

BrewManNH,

From my reading of the function it seems that the function only pages the memory to the hard drive if the pages are in use. Using it once the Marquee is deleted should free the memory completely. I found this quote while I was researching (sorry I cannot remember from exactly where):

"The working set of an application is not guaranteed to be reserved. When the application is idle or the the memory runs low the OS will eventually reclaim/reduce the working set of an application. So, calling the EmptyWorkingSet/SetProcessWorkingSetSize is just a way to clean up before the OS does it."

But I freely admit I am well ouside my comfort zone here so (as always) I am more than ready to hear that I am completely wrong! :D

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

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