Jump to content

UDF Marquee.au3 move or hide control


Belini
 Share

Recommended Posts

I'm using the UDF Marquee.au3 made by @Melba 23 and I want to move or hide a control without deleting and recreate this control, does anyone know how to do this?

My attempts:

#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, 400)

; 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)
$cButton_4 = GUICtrlCreateButton("Move Default Marquee Parameters", 10, 320, 300, 30, $BS_MULTILINE)
$cButton_5 = GUICtrlCreateButton("Hide Marquee Parameters", 10, 360, 300, 30, $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")
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!")
        Case $cButton_4
            GUICtrlSetPos($aMarquee[0], 30, 10, 50, 15)
            ControlMove("Marquee Example 1", "", $aMarquee[0], 30, 10, 50, 15)
        Case $cButton_5
            GUICtrlSetState($aMarquee[0], $GUI_HIDE)
    EndSwitch
WEnd

Func On_Exit()
    Exit
EndFunc   ;==>On_Exit

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   ;==>On_Place

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   ;==>Find_Taskbar

 

Edited by Belini
Link to comment
Share on other sites

Here ControlHide did not work for me, how did you use ControlHide?

ControlHide("Marquee Example 1", "", $aMarquee[0]); did not work for me

Link to comment
Share on other sites

ControlHide($gui, "", $aMarquee[0])  It also does not work.

11 hours ago, qwert said:

How about Control Hide and Control Show?  These work for me.

 

How did you do it when it worked?

Edited by Belini
Link to comment
Share on other sites

My use was simple: ControlHide($GUI, "", $gotoDate)

What I meant by $control = $aMarquee[0] was to eliminate the array reference from the statement. Just pass a variable. It's just something I've found that works in certain instances of other calls.

Link to comment
Share on other sites

$GUI = GUICreate("Marquee Example 1", 320, 400), but what is the content of $gotoDate?

Link to comment
Share on other sites

  • Moderators

Hi,

Try this Beta UDF to which I have added Hide/Show functions:

And here is a quick example script to show it working:

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

#include "Marquee_Mod.au3"

$hGUI = GUICreate("Marquee Hide/Show", 320, 320)

$iMarqueeIndex = _GUICtrlMarquee_Init()
_GUICtrlMarquee_Create($iMarqueeIndex, "I can be hidden and reshown", 10,  10, 300, 20)

$cButton_1 = GUICtrlCreateButton("Hide", 10, 220, 90, 90)
$cButton_2 = GUICtrlCreateButton("Show", 110, 220, 100, 90)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton_1
            _GUICtrlMarquee_Hide($iMarqueeIndex)
        Case $cButton_2
            _GUICtrlMarquee_Show($iMarqueeIndex)
    EndSwitch
WEnd

M23

Edited by Melba23
Beta code removed

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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