xzqd 发表于 2012-6-5 18:46:57

请教高手单选框与输入框问题【已解决】

本帖最后由 xzqd 于 2012-6-5 19:51 编辑


请问高手如何编辑清除输入框内容后单选框自动取消被选中状态
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 332, 153, 192, 124)
GUISetCursor (0)
$Radio1 = GUICtrlCreateRadio("测试", 16, 32, 49, 17)
$Input1 = GUICtrlCreateInput("123456", 56, 72, 137, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

haijie1223 发表于 2012-6-5 19:11:20

一个 radio能取消选择吗?

非典男人 发表于 2012-6-5 19:24:21

GUICtrlSetState($Radio1, $GUI_UNCHECKED)
思路,读取输入框内容如果为空,则上面的命令。

502762378 发表于 2012-6-5 19:36:15


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 332, 153, 192, 124)
GUISetCursor (0)
$Radio1 = GUICtrlCreateRadio("测试", 16, 32, 49, 17)
GUICtrlSetState($Radio1,1)
$Input1 = GUICtrlCreateInput("123456", 56, 72, 137, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        If GUICtrlRead($Input1) ="" And GUICtrlGetState($Radio1) = 80 Then GUICtrlSetState($Radio1,4)
      $nMsg = GUIGetMsg()
      Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
      EndSwitch
WEnd


haijie1223 发表于 2012-6-5 19:47:14

晕,原来还真的可以。
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 332, 153, 192, 124)
GUISetCursor(0)
$Radio1 = GUICtrlCreateRadio("测试", 16, 32, 49, 17)
$Input1 = GUICtrlCreateInput("123456", 56, 72, 137, 21)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
AdlibRegister("input")

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd

Func input()
        $sta = GUICtrlRead($Input1)
        Select
                Case $sta == ""
                        GUICtrlSetState($Radio1, $GUI_UNCHECKED)
                Case $sta <> ""
                        GUICtrlSetState($Radio1, $GUI_CHECKED)
        EndSelect
EndFunc   ;==>input

xzqd 发表于 2012-6-5 19:49:13

谢谢楼上高手帮忙

ooxxgod 发表于 2012-6-5 20:56:13

哈哈 发哥 没想到

hzxymkb 发表于 2012-6-5 22:35:07

回复 5# haijie1223


    发哥一出手,嘛事都是浮云!

haijie1223 发表于 2012-6-5 23:00:34

回复 8# hzxymkb


    别取笑我,水哥多多关照。

魔导 发表于 2012-6-5 23:08:42

{:1_257:}回复hzxymkb


    别取笑我,水哥多多关照。
haijie1223 发表于 2012-6-5 23:00 http://www.autoitx.com/images/common/back.gif
发哥 水哥 都到啦,小弟就拿点钱吧,不出丑咯

298311657 发表于 2012-6-5 23:56:02


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 332, 153, 192, 124)
$Radio1 = GUICtrlCreateRadio("测试", 16, 32, 49, 17)
$Input1 = GUICtrlCreateInput("", 56, 72, 137, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
WEnd

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode
    $iIDFrom = BitAND($iwParam, 0xFFFF)
    $iCode = BitShift($iwParam, 16)
    Switch $iIDFrom
      Case $Input1
            Switch $iCode
                Case $EN_UPDATE ; Sent when an edit control is about to redraw itself
                                        If Not StringLen(GUICtrlRead($Input1)) Then
                                                GUICtrlSetState($Radio1, $GUI_UNCHECKED)
                                        Else
                                                GUICtrlSetState($Radio1, $GUI_CHECKED)
                                        EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

aefj 发表于 2012-6-6 00:16:17

有高手哦,学习学习

aefj 发表于 2012-6-6 00:16:21

有高手哦,学习学习

xyhqqaa 发表于 2012-6-6 09:38:35

纯路过。。赚点小积分。。这还好不难。。。(*^__^*) 嘻嘻……

zerobin 发表于 2012-6-6 17:47:02

事件模式下的#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Radio1 = GUICtrlCreateRadio("Radio1", 144, 88, 97, 33)
GUICtrlSetState($radio1,$GUI_CHECKED)
$Input1 = GUICtrlCreateInput("Input1", 200, 176, 153, 21)
GUICtrlSetOnEvent(-1, "Input1Change")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        Sleep(100)
WEnd

Func Form1Close()
Exit
EndFunc
Func Input1Change()
        Select
                Case GUICtrlRead($Input1) = "" And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
                        GUICtrlSetState($radio1,$GUI_UNCHECKED)
        EndSelect
EndFunc
页: [1] 2
查看完整版本: 请教高手单选框与输入框问题【已解决】