找回密码
 加入
搜索
查看: 5874|回复: 24

[GUI管理] 如何实现输入框之间的数据互相随之即时改变?[已解决]

[复制链接]
发表于 2017-4-15 23:03:23 | 显示全部楼层 |阅读模式
本帖最后由 cashiba 于 2017-4-17 08:53 编辑
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("", 64, 32, 201, 21)
$Input2 = GUICtrlCreateInput("", 64, 80, 201, 21)
$Input3 = GUICtrlCreateInput("", 64, 128, 201, 21)
$Input4 = GUICtrlCreateInput("", 64, 176, 201, 21)
$Inputx = GUICtrlCreateInput("", 64, 240, 500, 89,$ws_border)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                case $inputx
                        GUICtrlSetData($inputx,GUICtrlRead($Input1)&"/"&GUICtrlRead($Input2)&"/"&GUICtrlRead($Input3)&"/"&GUICtrlRead($Input4))
        EndSwitch
WEnd
如上图及代码
如何实现:$input1、2、3、4输入框里输入数据,$inputx输入框里的数据随之即时变化;反之,$inputx里“/”分隔的四个部分数据里的任何一部分修改,在相应的$input1、2、3、4输入框里的数据也会随之即时改变。也就是即改即变。
上面的代码只能实现点击$inputx输入框后数据才会发生改变,不能自动随变。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2017-4-16 01:21:48 | 显示全部楼层
本帖最后由 xzf680 于 2017-4-16 01:23 编辑

看一下是不是这样
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("", 64, 32, 201, 21)
$Input2 = GUICtrlCreateInput("", 64, 80, 201, 21)
$Input3 = GUICtrlCreateInput("", 64, 128, 201, 21)
$Input4 = GUICtrlCreateInput("", 64, 176, 201, 21)
$Inputx = GUICtrlCreateInput("", 64, 240, 500, 89,$ws_border)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        If GUICtrlRead($Input1) <>"" Then GUICtrlSetData($inputx,GUICtrlRead($Input1)&"/"&GUICtrlRead($Input2)&"/"&GUICtrlRead($Input3)&"/"&GUICtrlRead($Input4))
        $nMsg = GUIGetMsg()
        Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                        Exit                
        EndSwitch
WEnd
发表于 2017-4-16 01:28:50 | 显示全部楼层
还是这样?
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("", 64, 32, 201, 21)
$Input2 = GUICtrlCreateInput("", 64, 80, 201, 21)
$Input3 = GUICtrlCreateInput("", 64, 128, 201, 21)
$Input4 = GUICtrlCreateInput("", 64, 176, 201, 21)
$Inputx = GUICtrlCreateInput("", 64, 240, 500, 89,$ws_border)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        If GUICtrlRead($Input1) <> "" Or GUICtrlRead($Input2) <> "" Or GUICtrlRead($Input3) <> "" Or GUICtrlRead($Input4) <> "" Then 
                        GUICtrlSetData($inputx,GUICtrlRead($Input1)&"/"&GUICtrlRead($Input2)&"/"&GUICtrlRead($Input3)&"/"&GUICtrlRead($Input4))
                EndIf
        $nMsg = GUIGetMsg()
        Switch $nMsg
                                Case $GUI_EVENT_CLOSE
                                        Exit                
        EndSwitch
WEnd

评分

参与人数 1金钱 +10 收起 理由
cashiba + 10

查看全部评分

发表于 2017-4-16 08:52:21 | 显示全部楼层
注册wm_command  消息,在udf的edit控件创建有示例
 楼主| 发表于 2017-4-16 10:40:09 | 显示全部楼层
还是这样?
xzf680 发表于 2017-4-16 01:28

试过这样直接赋值。但是不好使,第一一直爱闪烁,第二大输入框无法操作,光标动不了...
感觉是需要注册消息才好使,目前不太熟悉
发表于 2017-4-16 15:33:06 | 显示全部楼层
试过这样直接赋值。但是不好使,第一一直爱闪烁,第二大输入框无法操作,光标动不了...
感觉是需要注册消 ...
cashiba 发表于 2017-4-16 10:40


要注册消息
Func WM_COMMAND($hWnd, $msg, $WParam, $LParam)
发表于 2017-4-16 18:08:30 | 显示全部楼层
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("", 64, 32, 201, 21)
$Input2 = GUICtrlCreateInput("", 64, 80, 201, 21)
$Input3 = GUICtrlCreateInput("", 64, 128, 201, 21)
$Input4 = GUICtrlCreateInput("", 64, 176, 201, 21)
$Inputx = GUICtrlCreateInput("1", 64, 240, 500, 89,$ws_border)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

AdlibRegister('check',200)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                case $inputx
                        GUICtrlSetData($inputx,GUICtrlRead($Input1)&"/"&GUICtrlRead($Input2)&"/"&GUICtrlRead($Input3)&"/"&GUICtrlRead($Input4))
        EndSwitch
WEnd
       

Func check()
        If GUICtrlRead($inputx) <> GUICtrlRead($Input1)&"/"&GUICtrlRead($Input2)&"/"&GUICtrlRead($Input3)&"/"&GUICtrlRead($Input4) Then
                 GUICtrlSetData($inputx,GUICtrlRead($Input1)&"/"&GUICtrlRead($Input2)&"/"&GUICtrlRead($Input3)&"/"&GUICtrlRead($Input4))
         EndIf
EndFunc
发表于 2017-4-16 18:09:18 | 显示全部楼层
关键词:
AdlibRegister('check',200)
Func check()
        If GUICtrlRead($inputx) <> GUICtrlRead($Input1)&"/"&GUICtrlRead($Input2)&"/"&GUICtrlRead($Input3)&"/"&GUICtrlRead($Input4) Then
                 GUICtrlSetData($inputx,GUICtrlRead($Input1)&"/"&GUICtrlRead($Input2)&"/"&GUICtrlRead($Input3)&"/"&GUICtrlRead($Input4))
         EndIf
EndFunc

评分

参与人数 1金钱 +19 收起 理由
cashiba + 19

查看全部评分

发表于 2017-4-16 18:11:06 | 显示全部楼层
反之,$inputx里“/”分隔的四个部分数据里的任何一部分修改,在相应的$input1、2、3、4输入框里的数据也会随之即时改变

此处代码类推
 楼主| 发表于 2017-4-16 20:36:28 | 显示全部楼层
关键词:
AdlibRegister('check',200)
Func check()
If GUICtrlRead($inputx)  GUICtrlRead($In ...
fenhanxue 发表于 2017-4-16 18:09

对了,回调函数定时刷新数据也是一种方法....
发表于 2017-4-16 20:49:17 | 显示全部楼层
回复 10# cashiba

编辑框的数据要使输入框里的数据也会随之即时改变,这个有点难
发表于 2017-4-16 22:05:48 | 显示全部楼层
回复 1# cashiba

不就是這個的 變化應用而已??

http://www.autoitx.com/forum.php ... amp;highlight=INPUT

评分

参与人数 1金钱 +10 收起 理由
cashiba + 10 感谢....

查看全部评分

发表于 2017-4-16 22:31:27 | 显示全部楼层
看看是这样不

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("", 64, 32, 201, 21)
$Input2 = GUICtrlCreateInput("", 64, 80, 201, 21)
$Input3 = GUICtrlCreateInput("", 64, 128, 201, 21)
$Input4 = GUICtrlCreateInput("", 64, 176, 201, 21)
$Inputx = GUICtrlCreateInput("", 64, 240, 500, 89,$ws_border)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        Local $aaa = GUICtrlRead($inputx)  
        Local $bbb = GUICtrlRead($Input1)&"/"&GUICtrlRead($Input2)&"/"&GUICtrlRead($Input3)&"/"&GUICtrlRead($Input4)
        If  $aaa <> $bbb Then GUICtrlSetData($inputx,GUICtrlRead($Input1)&"/"&GUICtrlRead($Input2)&"/"&GUICtrlRead($Input3)&"/"&GUICtrlRead($Input4))
     
         $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit 
        EndSwitch
WEnd

评分

参与人数 1金钱 +19 收起 理由
cashiba + 19

查看全部评分

 楼主| 发表于 2017-4-16 23:21:51 | 显示全部楼层
看看是这样不
绿色风 发表于 2017-4-16 22:31

谢谢风侠....
 楼主| 发表于 2017-4-16 23:22:55 | 显示全部楼层
以上的方法好像都是只能实现单向随变。而且大输入框不能修改数据
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-3-29 02:08 , Processed in 0.103040 second(s), 31 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表