﻿;-- TIME_STAMP   2017-10-27 15:39:38

#include "GuiCtrlBusy.au3"
#include <GuiConstantsEx.au3>

#Region
; Creates an Busy control.
; _GuiCtrlBusy_Create      ([$_sTitle = ''[, $_sText = ''[, $_iAlign=2[, $_iX = -1[, $_iY = -1[, $_iTimeout = -1[, $_iTimeCounter = -1[, $_BGRtitle = -1[, $_BGRtext = -1
;                           [, $_RGBtopleft = -1[, $_RGBbottomright = -1[, $_bRotate = False]]]]]]]]]]]])
; Close one/all controls.
; _GuiCtrlBusy_Close       ([$_hWnd = -1])

; Für die Manipulation von Ctrl gilt einheitlich:
; optionale Parameter --> "Leerstring"="Wert wird beibehalten", "-1"="USER_DEFAULT" oder der übergebene Wert

; Sets for title line: title, show:nothing(0)/countdown(1)/clocktime(2), timeout, color.
; _GuiCtrlBusy_SetTitle    ($_hWnd, $_sTitle = ''[, $_iTimeCounter = ''[, $_iTimeout = ''[, $_BGRtitle = ''[, $_bSetOnTop = '']]]])

; Sets icon from any *.dll/*.ico file.
; _GuiCtrlBusy_SetIcon     ($_hWnd, $_sIconFile=''[, $_iIconID])

; Sets text /~color /~size /~style /~font.
; _GuiCtrlBusy_SetText     ($_hWnd, $_sText = ''[, $_BGRtext = ''[, $_iSize=''[, $_iStyle=''[, $_sFontname=''[, $_bSetOnTop = '']]]]])

; Sets an individual callback interval, opt. stops recalculation of ctrl size.
; _GuiCtrlBusy_SetCBInterval($_hWnd[, $_iInterval=$GCB_U_CALLBACK_INTERVAL[, $_bNoReCalc=False]])

; Stops (or allows) recalculation of control size while text or title is changed.
; _GuiCtrlBusy_StopRecalc  ($_hWnd[, $_bNoReCalc=True])

;Sets title/text/gradient colors.
; _GuiCtrlBusy_SetColors   ($_hWnd, $_BGRtitle = ''[, $_BGRtext = ''[, $_RGBtopleft = ''[, $_RGBbottomright = '']]])

; Sets gradient colors and direction.
; _GuiCtrlBusy_SetGradient ($_hWnd, $_RGBtopleft = ''[, $_RGBbottomright = ''[, $_bRotate = '']])

; Sets color-scheme/gradient-direction/optional ontop.
; _GuiCtrlBusy_SetScheme   ($_hWnd[, $_sScheme = ''[, $_bRotate = ''[, $_bSetOnTop = '']]])

; Gets array of one or all color schemes.
; _GuiCtrlBusy_GetScheme   ($_sScheme='')

; Adds a new color scheme, only valid at runtime.
; _GuiCtrlBusy_AddScheme   ($_sScheme, $_RGBtopleft, $_RGBbottomright, $_BGRtitle, $_BGRtext)

; Moves the control to x/y position, optional set ontop.
; _GuiCtrlBusy_SetPos      ($_hWnd, $_iX = ''[, $_iY = ''[, $_bSetOnTop = '']])

; Sets/Stops the control timeout.
; _GuiCtrlBusy_SetTimeout  ($_hWnd, $_iTimeout, $_iTimeCounter)

; Sets one (default: all) control on top.
; _GuiCtrlBusy_SetOnTop    ([$_hWnd = -1])

; Changes the default values for control creation.
; _GuiCtrlBusy_UserDefaults($_sParamValue[, $_sDelim = '|'])

; Gets a Dummy-ID, that will fired by closing ctrl. Use "GuiCtrlRead(Dummy)" to get Ctrl-hWnd.
; _GuiCtrlBusy_GetClosed   ()
#endregion

Opt('GUIOnEventMode', 1)

Global $gClicked = False

$hGui = GUICreate('Test', 300, 250, 100, 100)
GUISetOnEvent(-3, '_close')
GUICtrlCreateLabel('Mit Schliessen dieses Fensters' & @LF &  @LF & 'werden alle BusyCtrl beendet.', 30, 30)
$bt1 = GUICtrlCreateButton('Intervall Nr 6', 10, 100, 120, 20)
GUICtrlSetOnEvent(-1, '_onButton')
$bt2 = GUICtrlCreateButton('Font/Style Nr 7', 10, 130, 120, 20)
GUICtrlSetOnEvent(-1, '_onButton')
$bt3 = GUICtrlCreateButton('Countdown Nr 6', 10, 160, 120, 20)
GUICtrlSetOnEvent(-1, '_onButton')
$bt4 = GUICtrlCreateButton('New Scheme Nr 7', 10, 190, 120, 20)
GUICtrlSetOnEvent(-1, '_onButton')
GUISetState()


; Icon List: http://help4windows.com/windows_7_shell32_dll.shtml

$hBusy0 = _GuiCtrlBusy_Create()                                                                                                  ; all params as default
$hBusy1 = _GuiCtrlBusy_Create('Nr 1 und der Titel muss jetzt lang sein', 'Titel && Countdown: %C%\nScheme: Clouds', 2, 420,  50, 15, 0)  ; the default color scheme
$hBusy2 = _GuiCtrlBusy_Create('Nr 2', 'Titel && Countdown\nCountdown: %C%\nScheme: Coffee',                         2, 800,  50, 10, -1, 'coffee')
$hBusy3 = _GuiCtrlBusy_Create('Nr 3', 'Titel && Zeit\nMal etwas in die Breite gezogen Scheme: Darkness',            2, 420, 200,  0,  2, 'darkness', True)
$hBusy4 = _GuiCtrlBusy_Create('Der Titel ist mal deutlich länger und länger', 'Nur Titel\nScheme: Silver\nlinks',   0, 800, 200,  0,  0, 'silver', True)

$hBusy5 = _GuiCtrlBusy_Create('Nr 5', 'Titel && Zeit\nScheme: Fire\nrechts\nIntervall 2s',                          1, 100, 400,  0,  2, 'fire')
_GuiCtrlBusy_SetCBInterval($hBusy5, 2000) ; alle 2s aktualisieren
_GuiCtrlBusy_SetIcon($hBusy5, 'moricons.dll', 7)

$hBusy6 = _GuiCtrlBusy_Create('Nr 6', 'Titel && Zeit\nScheme: Sys_invers\nmitte\nIntervall 3s',                     2, 420, 400,  0,  2, 'sys_invers')
_GuiCtrlBusy_SetCBInterval($hBusy6, 3000) ; alle 3s aktualisieren
_GuiCtrlBusy_StopRecalc($hBusy6)

$hBusy7 = _GuiCtrlBusy_Create('Nr 7', 'Titel && Zeit\nScheme: Orange\nund eine Zeile #3\nBeenden mit Links-Klick',-1, 100, 550,  0,  2, 'orange', True)
GUISetOnEvent($GUI_EVENT_PRIMARYUP, '_CloseBusy')
Func _CloseBusy()
    _GuiCtrlBusy_Close(@GUI_WinHandle)
EndFunc

; Mit $WM_COMMAND auswertbar: $GCB_CLOSED, $GCB_LEFTSINGLE, $GCB_RIGHTSINGLE
GuiRegisterMsg($WM_COMMAND, '_MyCommand')


While 1
	Sleep(50)
WEnd

Func _onButton()
	Switch @GUI_CtrlId
		Case $bt1 ; $_hWnd, $_sTitle='', $_iTimeCounter='', $_iTimeout='', $_BGRtitle='', $_bSetOnTop=''
			_GuiCtrlBusy_SetCBInterval($hBusy6, 1000)
			_GuiCtrlBusy_SetText ($hBusy6, 'Intervall geändert\n1 Sekunde')
		Case $bt2 ; $_hWnd, $_sText='', $_BGRtext='', $_iSize='', $_iStyle='', $_sFontname='', $_bSetOnTop=''
			_GuiCtrlBusy_SetText ($hBusy7, '', '', 16, 1+4, 'Comic Sans MS')
		Case $bt3 ; $_hWnd, $_iTimeout, $_iTimeCounter=1
			If $gClicked Then
				_GuiCtrlBusy_SetTimeout($hBusy6, 0, 2)
				GUICtrlSetData($bt3, 'Countdown Nr 6')
			Else
				_GuiCtrlBusy_SetTimeout($hBusy6, 20, 1)
				GUICtrlSetData($bt3, 'Stop Countdown 6')
			EndIf
			$gClicked = Not $gClicked

		Case $bt4 ; $_hWnd, $_sScheme='', $_bRotate='', $_bSetOnTop=''
			_GuiCtrlBusy_SetScheme($hBusy7, 'forest')
			_GuiCtrlBusy_SetText($hBusy7, 'New Scheme\n"Forest"')
	EndSwitch
EndFunc

Func _close()
	Exit
EndFunc


Func _MyCommand($hWnd, $iMsg, $wParam, $lParam)
	Local $hWndFrom = $wParam
	Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
	Local $iCode = DllStructGetData($tNMHDR, "Code")
	If $iCode = $GCB_CLOSED Then
		Switch $hWndFrom
			Case $hBusy0
				ConsoleWrite('Busy-Ctrl "$hBusy0" beendet' & @CRLF)
			Case $hBusy1
				ConsoleWrite('Busy-Ctrl "$hBusy1" beendet' & @CRLF)
			Case $hBusy2
				ConsoleWrite('Busy-Ctrl "$hBusy2" beendet' & @CRLF)
			Case $hBusy6
				ConsoleWrite('Busy-Ctrl "$hBusy6" beendet' & @CRLF)
		EndSwitch
	ElseIf $iCode = $GCB_LEFTSINGLE Then
		Switch $hWndFrom
			Case $hBusy0
				ConsoleWrite('LEFT "$hBusy0"' & @CRLF)
			Case $hBusy1
				ConsoleWrite('LEFT "$hBusy1"' & @CRLF)
			Case $hBusy2
				ConsoleWrite('LEFT "$hBusy2"' & @CRLF)
			Case $hBusy3
				ConsoleWrite('LEFT "$hBusy3"' & @CRLF)
			Case $hBusy4
				ConsoleWrite('LEFT "$hBusy4"' & @CRLF)
			Case $hBusy5
				ConsoleWrite('LEFT "$hBusy5"' & @CRLF)
			Case $hBusy6
				ConsoleWrite('LEFT "$hBusy6"' & @CRLF)
			Case $hBusy7
				_GuiCtrlBusy_Close($hWndFrom)
				ConsoleWrite('LEFT "$hBusy7"' & @CRLF)
		EndSwitch
	ElseIf $iCode = $GCB_RIGHTSINGLE Then
		Switch $hWndFrom
			Case $hBusy0
				ConsoleWrite('RIGHT "$hBusy0"' & @CRLF)
			Case $hBusy1
				ConsoleWrite('RIGHT "$hBusy1"' & @CRLF)
			Case $hBusy2
				ConsoleWrite('RIGHT "$hBusy2"' & @CRLF)
			Case $hBusy3
				ConsoleWrite('RIGHT "$hBusy3"' & @CRLF)
			Case $hBusy4
				ConsoleWrite('RIGHT "$hBusy4"' & @CRLF)
			Case $hBusy5
				ConsoleWrite('RIGHT "$hBusy5"' & @CRLF)
			Case $hBusy6
				ConsoleWrite('RIGHT "$hBusy6"' & @CRLF)
			Case $hBusy7
				ConsoleWrite('RIGHT "$hBusy7"' & @CRLF)
		EndSwitch
	EndIf
	Return $GUI_RUNDEFMSG
EndFunc



; 0931-905450  buchhaltung@gebrueder-goetz.de
