Anarasius,
Кажется, Creat0R приводил пример одновременной работы 2-х функций:
Код:
#include <GUIConstantsEx.au3>
;
Opt("GUIOnEventMode", 1)
Global $ahCallBack[2], $iPrecent
$hGUI = GUICreate("ProgressBar", 400, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Main_Events")
$Progress = GUICtrlCreateProgress(10, 10, 300, 22)
$Status_Label = GUICtrlCreateLabel("0%", 330, 30, 30, 20)
$Button = GUICtrlCreateButton("Start", 150, 100, 50, 20)
GUICtrlSetOnEvent(-1, "_Main_Events")
GUISetState()
While 1
Sleep(100)
If $iPrecent > 0 Then
;Тут мы вызываем нашу функцию
Call("_SomeFunction_Proc")
EndIf
WEnd
Func _Main_Events()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
_CallBack_Free($ahCallBack)
Exit
Case $Button
If GUICtrlRead($Button) = "Stop" Then
GUICtrlSetData($Button, "Start")
_CallBack_Free($ahCallBack)
Else
GUICtrlSetData($Button, "Stop")
$ahCallBack = _CallBack_Init("_SetProgress_Proc", 10)
EndIf
EndSwitch
EndFunc ;==>_Main_Events
Func _SomeFunction_Proc()
While $iPrecent > 0
Sleep(1000)
MsgBox(0, "", "Наша функция работает на ряду с прогрессом :)... " & $iPrecent)
WEnd
EndFunc ;==>_SomeFunction_Proc
Func _SetProgress_Proc()
$iPrecent += 1
GUICtrlSetData($Progress, Round($iPrecent / 3))
GUICtrlSetData($Status_Label, Round($iPrecent / 3) & "%")
If $iPrecent > 300 Then
$iPrecent = 0
GUICtrlSetData($Status_Label, "100%")
GUICtrlSetData($Button, "Start")
_CallBack_Free($ahCallBack)
$ahCallBack = 0
Dim $ahCallBack[2] = [-1, -1]
EndIf
EndFunc ;==>_SetProgress_Proc
Func _CallBack_Init($sFuncName, $iTime, $sParam = "")
Local $hCallBack = DllCallbackRegister($sFuncName, "int", $sParam)
Local $aTimer = DllCall("user32.dll", "uint", "SetTimer", _
"hwnd", 0, "uint", 0, "int", $iTime, "ptr", DllCallbackGetPtr($hCallBack))
Local $ahCallBack[2] = [$hCallBack, $aTimer[0]]
Return $ahCallBack
EndFunc ;==>_CallBack_Init
Func _CallBack_Free($ahCallBack)
If $ahCallBack[0] <> -1 Then DllCallbackFree($ahCallBack[0])
If $ahCallBack[1] <> -1 Then DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $ahCallBack[1])
EndFunc ;==>_CallBack_Free
|