Sign in to follow this  
Followers 0
TheGrayMan

Newbie: creating Options window

7 posts in this topic

Hey all,

I've got a wee ticker app (based largely on Melba23's code) which is designed to display the contents of a text file. In order to be able to change various settings of this such as the file that it displays and the font size, I'm wanting to create a Settings GUI which will display when you choose a menu item.

I've worked out how to code the new GUI (I think!), but I'm not sure how to call it from the main program window. If I code it as an include file, the new GUI tries to run when I run the main program. Can you give me some pointers here?

Many thanks,

Ian

Share this post


Link to post
Share on other sites



TheGrayMan,

I suggest a read of the Managing Multiple GUIs tutorial in the Wiki - that should give you enough to go on. :)

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

I suggest a read of the Managing Multiple GUIs tutorial in the Wiki - that should give you enough to go on. :)

Well, I had seen that, but I wondered if (for the purposes I have in mind) it's leading me down a route that is needlessly complex. It seems to me that for an Options dialogue box, where you're not needing to interact with the primary GUI while the options box is up, that what "Managing Multiple GUIs" calls "disabling the first GUI" would be sufficient. Am I missing something? Will something horrible happen if I do this?

Ian

Share this post


Link to post
Share on other sites

TheGrayMan,

Will something horrible happen

Who knows? But I doubt the universe will end! :)

Post the code you have so far and I will take a look and offer some advice. :)

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

Post the code you have so far and I will take a look and offer some advice. :)

Thanks for the offer. OK, here's what I've ended up with. It seems to work, although I dare say seasoned programmers will look at it and shudder. :) Tips and suggestions more than welcome.

Main prog:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=..\Downloads\jean_victor_balin_icon_monitoring.ico
#AutoIt3Wrapper_outfile=SATicker.exe
#AutoIt3Wrapper_Res_Comment=SATicker - an alerting companion to Servers Alive
#AutoIt3Wrapper_Res_Fileversion=1.3.0.2
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Marquee.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <file.au3>

Local $AlertFile = ""
Global $DefaultAlertFileName = "http://monitoring/ticker.txt"
Global $AlertFileName = $DefaultAlertFileName
Local $AlertText = "Getting Data"
Local $OldAlertText = ""
Global $refreshflag = 0
Global $FirstTime = 1
Global $Hide = 0
Global $Blank = 0
Global $TickerColour = "white"
Global $TickerFontName = "Calibri"
Global $TickerFontSize = 14
Global $TickerHeight = int($TickerFontSize * 1.8)
Global $FileSource = "URL"

#include <Options window.au3>

If _MutexExists("SATicker") Then
; We know the script is already running. Let the user know.
    MsgBox(0, "Multiple instances not allowed!", "SATicker is already running. Check the icon in the tray.")
    Exit
EndIf

Func _MutexExists($sOccurenceName) ;prevent multiple instances running
    Local $ERROR_ALREADY_EXISTS = 183, $handle, $lastError

    $sOccurenceName = StringReplace($sOccurenceName, "\", ""); to avoid error
    $handle = DllCall("kernel32.dll", "int", "CreateMutex", "int", 0, "long", 1, "str", $sOccurenceName)

    $lastError = DllCall("kernel32.dll", "int", "GetLastError")
    Return $lastError[0] = $ERROR_ALREADY_EXISTS

EndFunc  ;==>_MutexExists

Func GetRegistry()
    $AlertFileName = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\SATicker", "AlertFileName")
    if @error<>0 then $AlertFileName = $DefaultAlertFileName
    $FileSource = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\SATicker", "FileSource")
    if @error<>0 then $FileSource = "URL"
    $TickerColour = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\SATicker", "TickerColour")
    if @error<>0 then $TickerColour = "white"
    $TickerFontName = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\SATicker", "TickerFontName")
    if @error<>0 then $TickerFontName = "Calibri"
    $TickerFontSize = number(RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\SATicker", "TickerFontSize"))
    if @error<>0 then $TickerFontSize = 14
    if $TickerFontSize = 0 then $TickerFontSize = 14
    $TickerHeight = int($TickerFontSize * 1.8)
EndFunc

Func WriteRegistry()
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SATicker", "AlertFileName", "REG_SZ", $AlertFileName)
    if @error<>0 then MsgBox(0,"Error","Error writing Alert File Name to registry")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SATicker", "FileSource", "REG_SZ", $FileSource)
    if @error<>0 then MsgBox(0,"Error","Error writing Alert File Source to registry")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SATicker", "TickerColour", "REG_SZ", $TickerColour)
    if @error<>0 then MsgBox(0,"Error","Error writing Ticker Colour to registry")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SATicker", "TickerFontName", "REG_SZ", $TickerFontName)
    if @error<>0 then MsgBox(0,"Error","Error writing Font Name to registry")
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\SATicker", "TickerFontSize", "REG_SZ", $TickerFontSize)
    if @error<>0 then MsgBox(0,"Error","Error writing Font Size to registry")
EndFunc

GetRegistry()
;SoundPlay(@WindowsDir & "\media\tada.wav",1)

Func ReadAlertFile()
    If $FileSource = "URL" then
        $InetFile = InetGet($AlertFileName, @TempDir & "\SAticker1.tmp",1,1)
        Do
            Sleep(250)
        Until InetGetInfo($InetFile, 2)    ; Check if the download is complete.
        Local $nBytes = InetGetInfo($InetFile, 0)
        InetClose($InetFile)   ; Close the handle to release resourcs.
    Else
        FileCopy($AlertFileName, @TempDir & "\SAticker1.tmp",1)
    EndIf
    $AlertFile = FileOpen(@TempDir & "\SAticker1.tmp", 0)
    $NewFile = FileOpen(@TempDir & "\SAticker2.tmp",2)
    $blankflag = 1
    While 1
        $line = FileReadLine($AlertFile)
        If @error = -1 Then
;~          End of file
            ExitLoop
        ElseIf @error = 1 Then
;~          File Error
            ExitLoop
        ElseIf $line ="</sa_report>" then
;~          Remove final line of report
            if $blankflag = 0 Then FileWriteLine($NewFile, ChrW(8226))
            ExitLoop
        ElseIf $line <>"" then
;~          Only keep non-blank lines
            FileWriteLine($NewFile, ChrW(8226) & ChrW(8195) & $line & ChrW(8195) & @CRLF)
            $blankflag = 0
        EndIf
    Wend
    FileClose($AlertFile)
    FileClose($NewFile)
    $AlertFile = FileOpen(@TempDir & "\SAticker2.tmp", 0)
    $AlertText = FileRead($AlertFile)
    If $FileSource = "UNC" then FileClose($AlertFile)
    ;~  $refreshflag = 0
    If $FirstTime = 1 Then
        $OldAlertText = $AlertText
        $FirstTime = 0
    EndIf
    If $OldAlertText <> $AlertText Then
        $refreshflag = 1
        $Hide = 0
        $Blank = 0
    EndIf
    $OldAlertText = $AlertText
    ; Check if file opened for reading OK
    If $AlertFile = -1 Then $AlertText = "Alerts file not found. Right click on tray icon and check location in Options screen."
EndFunc

ReadAlertFile()

Local $label = "Servers Alive Alert Ticker"
Global $aMarquee_Coords[4] = [0, 0, @DesktopWidth, $TickerHeight]
Global $fMarquee_Pos = "bottom"

Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu
Opt("TrayMenuMode", 3) ; Default tray menu items will not be shown.

Global $hTray_Hide_Item = TrayCreateItem("Hide until change")
TrayItemSetOnEvent(-1, "Marquee_Hide")
TrayCreateItem("")
Global $hTray_Top_Item = TrayCreateItem("Top")
TrayItemSetOnEvent(-1, "On_Place")
Global $hTray_Bot_Item = TrayCreateItem("Bottom")
TrayItemSetOnEvent(-1, "On_Place")
TrayCreateItem("")
Global $hTray_Options_Item = TrayCreateItem("Options")
TrayItemSetOnEvent(-1, "Options")
Global $hTray_About_Item = TrayCreateItem("About")
TrayItemSetOnEvent(-1, "About")
TrayCreateItem("")
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "On_Exit")

TraySetState()
Find_Taskbar($aMarquee_Coords)
If @error Then MsgBox(0, "Error", "Could not find taskbar")

$hGUI1 = GUICreate("SATicker", $aMarquee_Coords[2], $TickerHeight, $aMarquee_Coords[0], $aMarquee_Coords[1], $WS_POPUPWINDOW, 0x00000088)
AdlibRegister("Refresh", 10000)
_GUICtrlMarquee_SetScroll(0, Default, "left", 4, 0)
_GUICtrlMarquee_SetDisplay(1, 0x000000, $TickerColour, $TickerFontSize, $TickerFontName)
$hMarquee = _GUICtrlMarquee_Create($AlertText, 0, -1, $aMarquee_Coords[2], $TickerHeight, $label)

GUISetState()

If $AlertText = "" then
    $Blank = 1
    Marquee_Hide()
Else
    $Blank = 0
EndIf

While 1
    Sleep(10)
WEnd

Func Refresh()

    ReadAlertFile()
;~  MsgBox(0,$Hide,"$FirstTime = " & $FirstTime & @LF & "$Blank = " & $Blank & @LF & "$Hide = " &$Hide & @LF & "$refreshflag = " & $refreshflag & @LF & $AlertText)

    If $AlertText = "" then
        $Blank = 1
        Marquee_Hide()
    Else
        $Blank = 0
    EndIf

    If $refreshflag = 1 Then
        If WinExists("SATicker") Then
            GUICtrlDelete($hMarquee)
            if $Hide = 1 Then
                WinSetState("SATicker","",@SW_SHOW)
                $Hide = 0
                TrayItemDelete($hTray_Hide_Item)
                $hTray_Hide_Item = TrayCreateItem("Hide until change",-1,0)
                TrayItemSetOnEvent(-1, "Marquee_Hide")
            ElseIf $Blank = 0 Then
                WinSetState("SATicker","",@SW_SHOW)
                TrayItemDelete($hTray_Hide_Item)
                $hTray_Hide_Item = TrayCreateItem("Hide until change",-1,0)
                TrayItemSetOnEvent(-1, "Marquee_Hide")
            EndIf
            _GUICtrlMarquee_SetDisplay(1, 0x000000, $TickerColour, $TickerFontSize, $TickerFontName)
            $hMarquee = _GUICtrlMarquee_Create($AlertText, 0, -1, $aMarquee_Coords[2], $TickerHeight, $label)
            Find_Taskbar($aMarquee_Coords)
            WinMove($hGUI1, "", $aMarquee_Coords[0], $aMarquee_Coords[1], $aMarquee_Coords[2], $TickerHeight)
        $refreshflag = 0
        EndIf
    EndIf
EndFunc   ;==>Refresh

Func On_Exit()
    $quit=MsgBox(33,"Quit?","Are you sure you want to exit the ticker?")
    if $quit=1 then Exit
EndFunc

Func On_Place()

    If $fMarquee_Pos = "top" Then
        $fMarquee_Pos = "bottom"
    Else
        $fMarquee_Pos = "top"
    EndIf

    Find_Taskbar($aMarquee_Coords)
    WinMove($hGUI1, "", $aMarquee_Coords[0], $aMarquee_Coords[1], $aMarquee_Coords[2], $TickerHeight)

EndFunc

Func Marquee_Hide()

    If $Blank = 1 Then
        WinSetState("SATicker","",@SW_HIDE)
        TrayItemDelete($hTray_Hide_Item)
        $hTray_Hide_Item = TrayCreateItem("Show",-1,0)
        TrayItemSetOnEvent(-1, "Marquee_Hide")
    ElseIf $Hide = 0 then
        $Hide = 1
        WinSetState("SATicker","",@SW_HIDE)
        TrayItemDelete($hTray_Hide_Item)
        $hTray_Hide_Item = TrayCreateItem("Show",-1,0)
        TrayItemSetOnEvent(-1, "Marquee_Hide")
    Else
        $Hide = 0
        WinSetState("SATicker","",@SW_SHOW)
        TrayItemDelete($hTray_Hide_Item)
        $hTray_Hide_Item = TrayCreateItem("Hide until change",-1,0)
        TrayItemSetOnEvent(-1, "Marquee_Hide")
    EndIf
;~  Refresh()
EndFunc

Func Options()

    GUISetState(@SW_DISABLE, $hGUI1)
        OptionsWindow()
        GUIDelete($hGUIOptions)
        If $refreshflag = 1 Then Refresh()
    WriteRegistry()
    GUISetState(@SW_ENABLE, $hGUI1)

EndFunc

Func About()

    MsgBox(262208,"About...", "SATicker. A utility designed to complement Woodstone's Servers Alive monitoring system." & @LF & "Recent status changes will be shown in the ticker." & @LF & @LF & "Version " & FileGetVersion("SATicker.exe"))

EndFunc

Func Find_Taskbar(ByRef $aMarquee_Coords)

    ; Find systray and get size
    Local $iPrevMode = AutoItSetOption("WinTitleMatchMode", 4)
    Local $aTray_Pos = WinGetPos("classname=Shell_TrayWnd")
    AutoItSetOption("WinTitleMatchMode", $iPrevMode)

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

    ; Determine position of taskbar
    If $aTray_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 - $aTray_Pos[3] - $TickerHeight
        EndIf
    ElseIf $aTray_Pos[0] > 0 Then
        ; Taskbar at RIGHT so coords of the marquee are
        $aMarquee_Coords[0] = 0
        $aMarquee_Coords[2] = @DesktopWidth - $aTray_Pos[2]
        If $fMarquee_Pos = "top" Then
            $aMarquee_Coords[1] = 0
        Else
            $aMarquee_Coords[1] = @DesktopHeight - $TickerHeight
        EndIf
    ElseIf $aTray_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] = $aTray_Pos[3]
        Else
            $aMarquee_Coords[1] = @DesktopHeight - $TickerHeight
        EndIf
    ElseIf $aTray_Pos[3] = @DesktopHeight Then
        ; Taskbar at LEFT so coords of the marquee are
        $aMarquee_Coords[0] = $aTray_Pos[2]
        $aMarquee_Coords[2] = @DesktopWidth - $aTray_Pos[2]
        If $fMarquee_Pos = "top" Then
            $aMarquee_Coords[1] = 0
        Else
            $aMarquee_Coords[1] = @DesktopHeight - $TickerHeight
        EndIf
    EndIf

EndFunc

The Options Window:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <misc.au3>

Func OptionsWindow()

#Region ### START Koda GUI section ### Form=
Global $hGUIOptions = GUICreate("Options", 507, 258, 310, 177)
$inpFilename = GUICtrlCreateInput($AlertFileName, 126, 56, 289, 21)
$Label1 = GUICtrlCreateLabel("Alerts File", 38, 60, 80, 17)
$btnBrowse = GUICtrlCreateButton("Browse", 422, 54, 49, 25, $WS_GROUP)
If $FileSource = "URL" then GUICtrlSetState($btnBrowse, $GUI_HIDE)
$Label2 = GUICtrlCreateLabel("Font Size", 38, 90, 58, 17)
$comFontSize = GUICtrlCreateCombo($TickerFontSize, 126, 86, 121, 25)
GUICtrlSetData($comFontSize, "8|9|10|11|12|14|16|18|20|24|28|32", $TickerFontSize)
$Label3 = GUICtrlCreateLabel("Font Name", 38, 120, 58, 17)
$comFontName = GUICtrlCreateCombo($TickerFontName, 126, 116, 121, 25)
GUICtrlSetData($comFontName, "Verdana|Tahoma|Arial|Calibri|Times New Roman", $TickerFontName)
;~ $Label3 = GUICtrlCreateLabel("Chime on new alerts", 24, 168, 99, 17)
;~ $boxSound = GUICtrlCreateCheckbox("boxSound", 128, 168, 97, 17)
$Label4 = GUICtrlCreateLabel("Ticker colour", 38, 150, 66, 17)
$comColour = GUICtrlCreateCombo($TickerColour, 126, 146, 145, 25)
GUICtrlSetData($comColour, "white|black|yellow|gray|red|orange|pink|silver|maroon|purple|aqua|teal", $TickerColour)
$btnOK = GUICtrlCreateButton("OK", 432, 217, 49, 25, $WS_GROUP)
$btnCancel = GUICtrlCreateButton("Cancel", 372, 217, 49, 25, $WS_GROUP)
$Label5 = GUICtrlCreateLabel("Source for alerts file:", 38, 30, 104, 17)
GUIStartGroup()
$radURL = GUICtrlCreateRadio("HTTP (URL)", 144, 24, 81, 25)
If $FileSource = "URL" then GUICtrlSetState(-1, $GUI_CHECKED)
$radUNC = GUICtrlCreateRadio("File (UNC)", 254, 24, 73, 25)
If $FileSource = "UNC" then GUICtrlSetState(-1, $GUI_CHECKED)
GUIStartGroup()
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $btnCancel
                ExitLoop
            Case $btnBrowse
                $path=FileOpenDialog("Select File",@ScriptDir,"All(*.*)")
                GUICtrlSetData($inpFilename,$path)
            Case $btnOK
                $AlertFileName=GUICtrlRead($inpFilename)
                $TickerFontName=GUICtrlRead($comFontName)
                $TickerFontSize=number(GUICtrlRead($comFontSize))
                $TickerColour=GUICtrlRead($comColour)
                $TickerHeight = int($TickerFontSize * 1.8)
                $refreshflag = 1
                ExitLoop
            Case $radURL
                $FileSource = "URL"
                GUICtrlSetState($btnBrowse, $GUI_HIDE)
            Case $radUNC
                $FileSource = "UNC"
                GUICtrlSetState($btnBrowse, $GUI_SHOW)
        EndSwitch
    WEnd

EndFunc

And finally the marquee code:

#include-once

; #INDEX# =======================================================================================================================
; Title .........: Marquee
; Description ...: This module contains various Marquee functions
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
;_GUICtrlMarquee_SetScroll  : Sets movement parameters for Marquee
;_GUICtrlMarquee_SetDisplay : Sets display parameters for Marquee
;_GUICtrlMarquee_Create     : Creates Marquee
; ===============================================================================================================================

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

; #INCLUDES# ====================================================================================================================
#include <WindowsConstants.au3>
#include <WinAPI.au3>

; #GLOBAL VARIABLES# ============================================================================================================
Global $iMarquee_Loop       = 0
Global $sMarquee_Move       = "scroll"
Global $sMarquee_Direction  = "left"
Global $iMarquee_Scroll     = 6
Global $iMarquee_Delay      = 85
Global $iMarquee_Border     = 0
Global $vMarquee_TxtCol     = Default
Global $sMarquee_BkCol      = "White"
Global $sMarquee_FontFamily = "Tahoma"
Global $iMarquee_FontSize   = 12

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_SetScroll
; Description ...: Sets movement parameters for subsequent _GUICtrlCreateMarquee calls
; Syntax.........: _GUICtrlMarquee_SetScroll([$iLoop, [$sMove, [$sDirection, [$iScroll, [$iDelay]]]]])
; Parameters ....: $iLoop        - [optional] Number of loops to repeat. (Default = infinite)
;                                      Use "slide" movement to keep text visible after stopping
;                  $sMove        - [optional] Movement of text.  From  "scroll" (Default), "slide" and "alternate".
;                  $sDirection   - [optional] Direction of scrolling.  From "left" (Default), "right", "up" and "down".
;                  $iScroll      - [optional] Distance of each advance - controls speed of scrolling (Default = 6)
;                                      Higher numbers increase speed, lower numbers give smoother animation.
;                  $iDelay       - [optional] Time in milliseconds between each advance (Default = 85).
;                                      Higher numbers lower speed, lower numbers give smoother animation.
; Return values .: Success - Returns 0.
; Author ........: Melba 23, based on some original code by james3mg, trancexx and jscript "FROM BRAZIL"
; Related .......: _GUICtrlMarquee_Create, _GUICtrlMarquee_SetDisplay, ObjCreate
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func _GUICtrlMarquee_SetScroll( $iLoop = 0, $sMove = 'scroll', $sDirection = 'left', $iScroll = 6, $iDelay = 85)

    ; Errorcheck and set parameters
    If IsNumber($iLoop) Then $iMarquee_Loop = Int(Abs($iLoop))

    Switch $sMove
        Case 'alternate', 'slide'
            $sMarquee_Move = $sMove
        Case Else
            $sMarquee_Move = 'scroll'
    EndSwitch

    Switch $sDirection
        Case 'right', 'up', 'down'
            $sMarquee_Direction = $sDirection
        Case Else
            $sMarquee_Direction = 'left'
    EndSwitch

    If IsNumber($iScroll) Then $iMarquee_Scroll = Int(Abs($iScroll))

    If IsNumber($iDelay) Then $iMarquee_Delay = Int(Abs($iDelay))

EndFunc ;=> _GUICtrlMarquee_SetScroll

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_SetDisplay
; Description ...: Sets display parameters for subsequent _GUICtrlCreateMarquee calls
; Syntax.........: _GUICtrlMarquee_SetDisplay([$iBorder, [$vTxtCol, [$vBkCol, [$iPoint, [$sFont]]]])
; Parameters ....: $iBorder - [optional] 0 = None (Default), 1 = 1 pixel, 2 = 2 pixel, 3 = 3 pixel
;                  $vTxtCol - [optional] Colour for text (Default = system colour, -1 = unchanged)
;                  $vBkCol  - [optional] Colour for Marquee (Default = system colour, -1 = unchanged)
;                             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.
; Author ........: Melba 23, based on some original code by james3mg, trancexx and jscript "FROM BRAZIL"
; Related .......: _GUICtrlMarquee_Create, _GUICtrlMarquee_SetScroll, ObjCreate
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

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

    ; Errorcheck and set parameters
    Select
        Case $iBorder = Default
            $iMarquee_Border = 0
        Case $iBorder >= 0 And $iBorder <= 3
            $iMarquee_Border = Int(Abs($iBorder))
        Case Else
    EndSelect

    Select
        Case $vTxtCol = Default
            $vMarquee_TxtCol = _WinAPI_GetSysColor($COLOR_WINDOWTEXT)
        Case IsNumber($vTxtCol) = 1
            If $vTxtCol >= 0 And $vTxtCol <= 0xFFFFFF Then $vMarquee_TxtCol = Int($vTxtCol)
        Case Else
            $vMarquee_TxtCol = $vTxtCol
    EndSelect

    Select
        Case $vBkCol = Default
            $sMarquee_BkCol = _WinAPI_GetSysColor($COLOR_WINDOW)
        Case  IsNumber($vBkCol) = 1
            If $vBkCol >= 0 And $vBkCol <= 0xFFFFFF Then $sMarquee_BkCol = Int($vBkCol)
        Case Else
            $sMarquee_BkCol = $vBkCol
    EndSelect

    Select
        Case $iPoint = Default
            $iMarquee_FontSize = 12
        Case $iPoint = -1
        Case Else
            If IsNumber($iPoint) Then $iMarquee_FontSize = Int($iPoint/.75)
    EndSelect

    Select
        Case $sFont = Default
            $sMarquee_FontFamily = "Tahoma"
        Case $sFont = ""
        Case Else
            If IsString($sFont) Then $sMarquee_FontFamily = $sFont
    EndSelect

EndFunc ;=> _GUICtrlMarquee_SetDisplay

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlMarquee_Create
; Description ...: Creates a Marquee Label control for the GUI
; Syntax.........: _GUICtrlMarquee_Create( $sText, $iLeft, $iTop, $iWidth, $iHeight, [$sTipText])
; Parameters ....: $sText   - The text (or HTML markup) the Marquee should display.
;                  $iLeft   - The Left side of the control. If -1 is used then left will be computed according to GUICoordMode.
;                  $iTop    - The Top of the control. If -1 is used then left will be computed according to GUICoordMode.
;                  $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 the identifier (controlID) of the new Marquee control.
;                  Failure - Returns 0
; 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 'methods' or 'properties' on the $ObjectVar.
; Related .......: _GUICtrlMarquee_SetDisplay, _GUICtrlMarquee_SetScroll, ObjCreate
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

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

    ; Declar Local variables
    Local $oShell, $iCtrlID

    $oShell = ObjCreate("Shell.Explorer.2")
    If Not IsObj($oShell) Then Return SetError(1, 0, -1)

    $iCtrlID = GUICtrlCreateObj($oShell, $iLeft, $iTop, $iWidth, $iHeight)

    $oShell.navigate("about:blank")
    While $oShell.busy
        Sleep(100)
    WEnd

    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=" & $iMarquee_Loop)
        .writeln("behavior=" & $sMarquee_Move)
        .writeln("direction=" & $sMarquee_Direction)
        .writeln("scrollamount=" & $iMarquee_Scroll)
        .writeln("scrolldelay=" & $iMarquee_Delay)
        .write(">")
        .write($sText)
        .body.title = $sTipText
        .body.topmargin = 0
        .body.leftmargin = 0
        .body.scroll = "no"
        .body.style.color = $vMarquee_TxtCol
        .body.bgcolor = $sMarquee_BkCol
        .body.style.borderWidth = $iMarquee_Border
        .body.style.fontFamily = $sMarquee_FontFamily
        .body.style.fontSize = $iMarquee_FontSize
    EndWith

    Return $iCtrlID

EndFunc ;=> _GUICtrlMarquee_Create

Cheers,

Ian

Share this post


Link to post
Share on other sites

TheGrayMan,

I did not shudder too much, I promise! :D

First - there is nothing wrong with your implementation of the "Options" dialog. :)

Second - I would strongly recommend that you adopt a standard structure for your scripts. This one is all over the place and it was hard to work out exactly what was going on. A good template for any future scripts you write would be:

1. Compiler directives (i.e. #AutoIt3Wrapper_au3check_parameters)

2. #includes (i.e. #include <Array.au3>)

3. Opt() statements

4. Global variable declarations

5. Initial script code

6. Idle loop (either GUIGetMsg or a simple Sleep)

7. Functions

With liberal use of comments throughout to help others (and you after a few months!)

This is pretty generally regarded as a sensible way to structure the code. :)

M23

P.S. I am looking at the other question, so please be patient. :P


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

Excellent - that's really helpful, thanks! I'll try to put in some structure...

Ian

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