#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <Timers.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
Opt('MustDeclareVars', 1)
Global $iMemo, $hStatusBar, $progress, $percent = 0, $direction = 1
_Example_CallBack()
Func _Example_CallBack()
Local $hGUI, $iTimerProgress, $btn_change, $iWait = 10, $btn_state
Local $aParts[3] = [75, 330, -1]
$hGUI = GUICreate('Timers Using CallBack Function(s)', 400, 320)
$iMemo = GUICtrlCreateEdit('', 2, 32, 396, 226, BitOR($WS_HSCROLL, $WS_VSCROLL))
GUICtrlSetFont($iMemo, 9, 400, 0, 'Courier New')
$btn_state = GUICtrlCreateButton('Start', 150, 265, 100, 25)
GUICtrlSetState($btn_change, $GUI_DISABLE)
$hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts)
_GUICtrlStatusBar_SetText($hStatusBar, 'Timers')
_GUICtrlStatusBar_SetText($hStatusBar, @TAB & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC), 2)
_GUICtrlStatusBar_SetText($hStatusBar, @TAB & 'Здесь будет ProgressBar', 1)
$progress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
_GUICtrlStatusBar_EmbedControl($hStatusBar, 1, GUICtrlGetHandle($progress))
GUICtrlSetState($progress, $GUI_HIDE)
GUISetState()
_Timer_SetTimer($hGUI, 1000, '_UpdateStatusBarClock')
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $btn_state
GUICtrlSetState($btn_state, $GUI_DISABLE)
GUICtrlSetData($progress, 0)
GUICtrlSetState($progress, $GUI_SHOW)
$iTimerProgress = _Timer_SetTimer($hGUI, 1000, '_UpdateProgressBar')
For $i = 1 To 100
MemoWrite($i & ' Test')
Sleep(250)
Next
MsgBox(64, 'Info', '100', 0, $hGUI)
GUICtrlSetData($iMemo, '')
For $i = 100 To 1 Step -1
MemoWrite($i & ' Test')
Sleep(250)
Next
_Timer_KillTimer($hGUI, $iTimerProgress)
GUICtrlSetState($progress, $GUI_HIDE)
MsgBox(64, 'Info', '1', 0, $hGUI)
GUICtrlSetData($iMemo, '')
GUICtrlSetState($btn_state, $GUI_ENABLE)
EndSwitch
WEnd
GUIDelete()
EndFunc ;==>_Example_CallBack
Func _UpdateStatusBarClock($hWnd, $Msg, $iIDTimer, $dwTime)
#forceref $hWnd, $Msg, $iIDTimer, $dwTime
_GUICtrlStatusBar_SetText($hStatusBar, @TAB & StringFormat('%02d:%02d:%02d', @HOUR, @MIN, @SEC), 2)
EndFunc ;==>_UpdateStatusBarClock
Func _UpdateProgressBar($hWnd, $Msg, $iIDTimer, $dwTime)
#forceref $hWnd, $Msg, $iIDTimer, $dwTime
$percent += 5 * $direction
GUICtrlSetData($progress, $percent)
If $percent = 100 Or $percent = 0 Then $direction *= -1
EndFunc ;==>_UpdateProgressBar
Func MemoWrite($sMessage)
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite