[已解决] 请问滑动条与上下键输入框如何互相关联数值?
本帖最后由 chishingchan 于 2016-1-21 17:48 编辑如何让:
当滑动滑动条的光标时,输入框的数字相对变化;
当输入框的数字变化时,滑动条的光标相对变化。
谢谢!#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("滑动条与上下键输入框互相关联",320,240)
$Slider1 = GUICtrlCreateSlider(10,10,80,20)
GUICtrlSetLimit(-1,100,0)
GUICtrlSetData($Slider1,50)
$Input1 = GUICtrlCreateInput("50",90,10,50,20)
GUICtrlCreateUpdown(-1)
GUISetState(@SW_SHOW)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUICreate('滑动条与上下键输入框互相关联', 320, 240)
$Slider1 = GUICtrlCreateSlider(10, 10, 80, 20)
GUICtrlSetLimit(-1, 100, 0)
GUICtrlSetData($Slider1, 50)
$Input1 = GUICtrlCreateInput('50', 90, 10, 50, 20)
$updown = GUICtrlCreateUpdown(-1)
GUISetState()
While 1
Switch GUIGetMsg()
Case -3
Exit
Case $Slider1
GUICtrlSetData($Input1, (GUICtrlRead($Slider1)))
Case $updown
GUICtrlSetData($Slider1, (GUICtrlRead($Input1)))
EndSwitch
WEnd
本帖最后由 chishingchan 于 2016-1-20 20:05 编辑
回复 2# afan
谢谢 afan!基本上没问题。但还发现有改善的地方:
1、输入框中输入数字,滑动条未能跟随变化;
2、滑动条光标滑动未能实时显示数字变化;
3、刚才又发现了一个问题:点击上下键输入框的数字超100了。 搜索了一下帖子,借用了一个函数(还没看的懂),上面第2条可以了,第1条还不行。Global Const $WM_HSCROLL = 0x0114
GUICreate('滑动条与上下键输入框互相关联', 320, 240)
$Slider1 = GUICtrlCreateSlider(10, 10, 80, 20)
$hSlider1 = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 100, 0)
GUICtrlSetData($Slider1, 50)
$Input1 = GUICtrlCreateInput('50', 90, 10, 50, 20)
$hInput1 = GUICtrlGetHandle(-1)
$Updown = GUICtrlCreateUpdown(-1)
$hUpdown1 = GUICtrlGetHandle(-1)
GUIRegisterMsg($WM_HSCROLL, 'WM_HSCROLL')
GUISetState()
Do
Until GUIGetMsg() = -3
Func WM_HSCROLL($Hwnd, $Msg, $Wparam, $Lparam)
Switch $Lparam
Case $hSlider1
GUICtrlSetData($Input1, GUICtrlRead($Slider1))
Case $hInput1
GUICtrlSetData($Slider1, GUICtrlRead($Input1))
EndSwitch
EndFunc ;==>WM_HSCROLL 用着先,再次感谢 afan !Global Const $WM_HSCROLL = 0x0114
GUICreate('滑动条与上下键输入框互相关联', 320, 240)
$Slider1 = GUICtrlCreateSlider(10, 10, 80, 20)
$hSlider1 = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 100, 0)
GUICtrlSetData($Slider1, 50)
$Input1 = GUICtrlCreateInput('50', 90, 10, 50, 20)
$Updown1 = GUICtrlCreateUpdown(-1)
GUIRegisterMsg($WM_HSCROLL, 'WM_HSCROLL')
GUISetState()
Do
Switch GUIGetMsg()
Case $Updown1
GUICtrlSetData($Slider1, (GUICtrlRead($Input1)))
EndSwitch
Until GUIGetMsg() = -3
Func WM_HSCROLL($Hwnd, $Msg, $Wparam, $Lparam)
Switch $Lparam
Case $hSlider1
GUICtrlSetData($Input1, GUICtrlRead($Slider1))
EndSwitch
EndFunc ;==>WM_HSCROLL 回复 5# chishingchan
1、输入框中输入数字,滑动条未能跟随变化;
2、滑动条光标滑动未能实时显示数字变化;
3、刚才又发现了一个问题:点击上下键输入框的数字超100了。
以上问题都解决了??? 回复 6# chzj589 Global Const $WM_HSCROLL = 0x0114
GUICreate('滑动条与上下键输入框互相关联',320,240)
$Slider1 = GUICtrlCreateSlider(10,10,80,20)
$hSlider1 = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1,100,0)
GUICtrlSetData($Slider1,50)
$Input1 = GUICtrlCreateInput('50',90,10,50,20)
$Updown1 = GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1,100,0)
GUIRegisterMsg($WM_HSCROLL, 'WM_HSCROLL')
GUISetState()
Do
Switch GUIGetMsg()
Case $Updown1
GUICtrlSetData($Slider1, (GUICtrlRead($Input1)))
EndSwitch
Until GUIGetMsg() = -3
Func WM_HSCROLL($Hwnd, $Msg, $Wparam, $Lparam)
Switch $Lparam
Case $hSlider1
GUICtrlSetData($Input1, GUICtrlRead($Slider1))
EndSwitch
EndFunc ;==>WM_HSCROLL
回复 7# chishingchan
3、刚才又发现了一个问题:点击上下键输入框的数字超100了。
加上:
GUICtrlSetLimit($Input1,100)
这不都解决了!
页:
[1]