chishingchan 发表于 2016-11-25 22:23:36

[已解决] ]如何设置 GUICtrlCreateUpdown 增减大小为 0.1 或100

本帖最后由 chishingchan 于 2016-11-28 17:18 编辑

GUICtrlCreateUpdown 控件按上下箭头默认是 1,可不可以设置为 0.1 ?或者以 100 增减?谢谢!

答案在 5 楼。

heroxianf 发表于 2016-11-26 01:51:53

还有这个函数,看了帮助没有什么参数设置,顶一下。

chishingchan 发表于 2016-11-26 14:36:09

暂时使用输入控件合并。

heroxianf 发表于 2016-11-26 15:35:25

回复 3# chishingchan


    能不能添加事件,加了时候 从新设置控件的值

kk_lee69 发表于 2016-11-28 16:49:38

回复 1# chishingchan
#include <GuiConstantsEx.au3>
#include <EditConstants.au3>

Global $Last_Set_Value = 0

$GUI = GUICreate("Test Script", 300, 200)

$Input = GUICtrlCreateInput(0, 20, 40, 80, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY))
$UpDown = GUICtrlCreateUpdown($Input)
GUICtrlSetBkColor($Input, 0xFFFFFF)

GUISetState(@SW_SHOW, $GUI)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
      Case $GUI_EVENT_CLOSE
            Exit
      Case $UpDown
            If Mod(GUICtrlRead($Input), 10) = 0 Then
                GUICtrlSetData($Input, GUICtrlRead($Input)/10&".0")
            Else
                GUICtrlSetData($Input, GUICtrlRead($Input)/10)
            EndIf
    EndSwitch
WEnd

chishingchan 发表于 2016-12-3 21:18:14

本帖最后由 chishingchan 于 2016-12-3 21:19 编辑

回复 5# kk_lee69


    这个帖子总结早了!请给个上下箭头在 400 至 -800 之间,每按一次下下箭头加减100的例子,默认值-400,谢谢!

kk_lee69 发表于 2016-12-3 22:20:16

回复 6# chishingchan

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $title, $input1, $input2, $updown, $iUpDown = 0, $iCurrent = -400

$title = "My GUI UpDown"
GUICreate($title, -1, -1, -1, -1, $WS_SIZEBOX)

$input1 = GUICtrlCreateInput(StringFormat("%#.1f", $iCurrent), 10, 10, 100, 20); Current value

$input2 = GUICtrlCreateInput(0, 110, 10, 20, 20); UpDown offset value
$updown = GUICtrlCreateUpdown($input2)

GUISetState()

; Update the current value until the dialog is closed
Do
    $iUpDown = Number(GUICtrlRead($input2))
    If $iUpDown <> 0 Then
      $iCurrent += ($iUpDown * 100)
                IF $iCurrent >= 400 Then
                        $iCurrent=400
                ElseIf $iCurrent <= -800 Then
                        $iCurrent=-800
                EndIf
      GUICtrlSetData($input1, StringFormat("%#.1f", $iCurrent))
      GUICtrlSetData($input2, 0)
    EndIf
Until GUIGetMsg() = $GUI_EVENT_CLOSE

chishingchan 发表于 2016-12-4 13:45:15

回复 7# kk_lee69


    谢谢!昨天晚上我想了很久也想到处理方法,请点评,谢谢!#include <GuiConstantsEx.au3>
#include <EditConstants.au3>

Global $Last_Set_Value = 0 ,$L=-400

$GUI = GUICreate("Test Script", 300, 200)

$Input = GUICtrlCreateInput(-400, 20, 40, 80, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY))
$UpDown = GUICtrlCreateUpdown($Input)
GUICtrlSetLimit($UpDown, 400, -800)
GUICtrlSetBkColor($Input, 0xFFFFFF)

GUISetState(@SW_SHOW, $GUI)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
      Case $GUI_EVENT_CLOSE
            Exit
      Case $UpDown
                If GUICtrlRead($Input) > $L Then
                        $L = GUICtrlRead($Input) + 99
                        GUICtrlSetData($Input, $L)
                ElseIf GUICtrlRead($Input) < $L Then
                        $L = GUICtrlRead($Input) - 99
                        GUICtrlSetData($Input, $L)
                EndIf
    EndSwitch
WEnd

gq0971 发表于 2017-4-26 10:19:43

十分感谢!
页: [1]
查看完整版本: [已解决] ]如何设置 GUICtrlCreateUpdown 增减大小为 0.1 或100