- Сообщения
- 5,379
- Репутация
- 2,724
Наиболее "правильный" на мой взгляд сопособ организации "живого" slider'а. Не нагружает основной цикл.
Код:
#Include <EditConstants.au3>
#Include <GUIConstantsEx.au3>
#Include <SliderConstants.au3>
#Include <WindowsConstants.au3>
GUICreate('MyGUI', 120, 200)
$Input = GUICtrlCreateInput('50', 70, 10, 27, 19, BitOR($ES_CENTER, $ES_READONLY))
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Slider = GUICtrlCreateSlider(24, 10, 26, 180, BitOR($TBS_AUTOTICKS, $TBS_VERT, $WS_TABSTOP))
GUICtrlSetLimit(-1, 100, 0)
GUICtrlSetData(-1, 50)
$hSlider = GUICtrlGetHandle(-1)
$Dummy = GUICtrlCreateDummy()
;GUIRegisterMsg($WM_HSCROLL, 'WM_HVSCROLL')
GUIRegisterMsg($WM_VSCROLL, 'WM_HVSCROLL')
GUISetState()
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Dummy
GUICtrlSetData($Input, 100 - GUICtrlRead($Dummy))
EndSwitch
WEnd
Func WM_HVSCROLL($hWnd, $iMsg, $wParam, $lParam)
Switch $iMsg
Case $WM_HSCROLL
Case $WM_VSCROLL
Switch $lParam
Case $hSlider
GUICtrlSendToDummy($Dummy, GUICtrlRead($Slider))
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_HVSCROLL