找回密码
 加入
搜索
查看: 4058|回复: 4

[GUI管理] 按条件显示(已解决)

[复制链接]
发表于 2015-6-24 09:22:04 | 显示全部楼层 |阅读模式
本帖最后由 westmood 于 2015-6-24 13:40 编辑

下面这个怎么选择A的时候 AA显示,选择B的时候BB显示,选择C的时候CC显示?
  1. #include <ButtonConstants.au3>
  2. #include <GUIConstantsEx.au3>
  3. #include <WindowsConstants.au3>
  4. #Region ### START Koda GUI section ### Form=
  5. $Form1 = GUICreate("Form1", 615, 438, 637, 259)
  6. $Radio1 = GUICtrlCreateRadio("A", 104, 32, 113, 17)
  7. $Radio2 = GUICtrlCreateRadio("B", 104, 72, 113, 17)
  8. $Radio3 = GUICtrlCreateRadio("C", 104, 112, 113, 17)
  9. $Group1 = GUICtrlCreateGroup("AA", 48, 192, 137, 193)
  10. $Checkbox1 = GUICtrlCreateCheckbox("AAA", 64, 232, 97, 17)
  11. GUICtrlCreateGroup("", -99, -99, 1, 1)
  12. $Group2 = GUICtrlCreateGroup("BB", 208, 192, 137, 193)
  13. $Checkbox2 = GUICtrlCreateCheckbox("BBB", 224, 232, 97, 17)
  14. GUICtrlCreateGroup("", -99, -99, 1, 1)
  15. $Group3 = GUICtrlCreateGroup("CC", 360, 192, 137, 193)
  16. $Checkbox3 = GUICtrlCreateCheckbox("CCC", 376, 232, 97, 17)
  17. GUICtrlCreateGroup("", -99, -99, 1, 1)
  18. GUISetState(@SW_SHOW)
  19. #EndRegion ### END Koda GUI section ###

  20. While 1
  21.         $nMsg = GUIGetMsg()
  22.         Switch $nMsg
  23.                 Case $GUI_EVENT_CLOSE
  24.                         Exit

  25.         EndSwitch
  26. WEnd
复制代码
发表于 2015-6-24 12:05:41 | 显示全部楼层
是不是想这样?   我只会笨办法
  1. #include <ButtonConstants.au3>
  2. #include <GUIConstantsEx.au3>
  3. #include <WindowsConstants.au3>
  4. #Region ### START Koda GUI section ### Form=
  5. $Form1 = GUICreate("Form1", 615, 438, 637, 259)
  6. $Radio1 = GUICtrlCreateRadio("A", 104, 32, 113, 17)
  7. $Radio2 = GUICtrlCreateRadio("B", 104, 72, 113, 17)
  8. $Radio3 = GUICtrlCreateRadio("C", 104, 112, 113, 17)
  9. $Group1 = GUICtrlCreateGroup("AA", 48, 192, 137, 193)
  10. $Checkbox1 = GUICtrlCreateCheckbox("AAA", 64, 232, 97, 17)
  11. GUICtrlCreateGroup("", -99, -99, 1, 1)
  12. $Group2 = GUICtrlCreateGroup("BB", 208, 192, 137, 193)
  13. $Checkbox2 = GUICtrlCreateCheckbox("BBB", 224, 232, 97, 17)
  14. GUICtrlCreateGroup("", -99, -99, 1, 1)
  15. $Group3 = GUICtrlCreateGroup("CC", 360, 192, 137, 193)
  16. $Checkbox3 = GUICtrlCreateCheckbox("CCC", 376, 232, 97, 17)
  17. GUICtrlCreateGroup("", -99, -99, 1, 1)
  18. GUISetState(@SW_SHOW)
  19. #EndRegion ### END Koda GUI section ###
  20. Opt("GUIOnEventMode", 1)
  21. GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
  22. GUICtrlSetOnEvent($Radio1, "RadioClick")
  23. GUICtrlSetOnEvent($Radio2, "RadioClick")
  24. GUICtrlSetOnEvent($Radio3, "RadioClick")

  25. GUICtrlSetState($Group1, $GUI_HIDE)
  26. GUICtrlSetState($Group2, $GUI_HIDE)
  27. GUICtrlSetState($Group3, $GUI_HIDE)
  28. GUICtrlSetState($Checkbox1, $GUI_HIDE)
  29. GUICtrlSetState($Checkbox2, $GUI_HIDE)
  30. GUICtrlSetState($Checkbox3, $GUI_HIDE)
  31. While 1
  32.         Sleep(200)
  33. WEnd
  34. Func Form1Close()
  35.         Exit
  36. EndFunc
  37. Func RadioClick()
  38.         Select
  39.                 Case GUICtrlRead($Radio1)=1
  40.                         GUICtrlSetState($Group1, $GUI_SHOW)
  41.                         GUICtrlSetState($Checkbox1, $GUI_SHOW)
  42.                         GUICtrlSetState($Group2, $GUI_HIDE)
  43.                         GUICtrlSetState($Checkbox2, $GUI_HIDE)
  44.                         GUICtrlSetState($Group3, $GUI_HIDE)
  45.                         GUICtrlSetState($Checkbox3, $GUI_HIDE)
  46.                 Case GUICtrlRead($Radio2)=1
  47.                         GUICtrlSetState($Group2, $GUI_SHOW)
  48.                         GUICtrlSetState($Checkbox2, $GUI_SHOW)
  49.                         GUICtrlSetState($Group1, $GUI_HIDE)
  50.                         GUICtrlSetState($Checkbox1, $GUI_HIDE)
  51.                         GUICtrlSetState($Group3, $GUI_HIDE)
  52.                         GUICtrlSetState($Checkbox3, $GUI_HIDE)
  53.                 Case GUICtrlRead($Radio3)=1
  54.                         GUICtrlSetState($Group3, $GUI_SHOW)
  55.                         GUICtrlSetState($Checkbox3, $GUI_SHOW)
  56.                         GUICtrlSetState($Group1, $GUI_HIDE)
  57.                         GUICtrlSetState($Checkbox1, $GUI_HIDE)
  58.                         GUICtrlSetState($Group2, $GUI_HIDE)
  59.                         GUICtrlSetState($Checkbox2, $GUI_HIDE)
  60.         EndSelect
  61. EndFunc
复制代码
发表于 2015-6-24 13:29:50 | 显示全部楼层
根据2楼的代码,加选中和取消。
  1. #include <ButtonConstants.au3>
  2. #include <GUIConstantsEx.au3>
  3. #include <WindowsConstants.au3>
  4. #Region ### START Koda GUI section ### Form=
  5. $Form1 = GUICreate("Form1", 615, 438, 637, 259)
  6. $Radio1 = GUICtrlCreateRadio("A", 104, 32, 113, 17)
  7. $Radio2 = GUICtrlCreateRadio("B", 104, 72, 113, 17)
  8. $Radio3 = GUICtrlCreateRadio("C", 104, 112, 113, 17)
  9. $Radio4 = GUICtrlCreateRadio("取消", 104, 152, 113, 17)
  10. $Group1 = GUICtrlCreateGroup("AA", 48, 192, 137, 193)
  11. $Checkbox1 = GUICtrlCreateCheckbox("AAA", 64, 232, 97, 17)
  12. GUICtrlCreateGroup("", -99, -99, 1, 1)
  13. $Group2 = GUICtrlCreateGroup("BB", 208, 192, 137, 193)
  14. $Checkbox2 = GUICtrlCreateCheckbox("BBB", 224, 232, 97, 17)
  15. GUICtrlCreateGroup("", -99, -99, 1, 1)
  16. $Group3 = GUICtrlCreateGroup("CC", 360, 192, 137, 193)
  17. $Checkbox3 = GUICtrlCreateCheckbox("CCC", 376, 232, 97, 17)
  18. GUICtrlCreateGroup("", -99, -99, 1, 1)

  19. #EndRegion ### END Koda GUI section ###
  20. GUICtrlSetState($Group1, $GUI_HIDE)
  21. GUICtrlSetState($Checkbox1, $GUI_HIDE)
  22. GUICtrlSetState($Group2, $GUI_HIDE)
  23. GUICtrlSetState($Checkbox2, $GUI_HIDE)
  24. GUICtrlSetState($Group3, $GUI_HIDE)
  25. GUICtrlSetState($Checkbox3, $GUI_HIDE)
  26. While 1
  27.         GUISetState(@SW_SHOW)
  28.         $nMsg = GUIGetMsg()
  29.         Switch $nMsg
  30.                
  31.                 Case $GUI_EVENT_CLOSE
  32.                        
  33.                         Exit
  34.                 Case $Radio1
  35.                        
  36.                         GUICtrlSetState($Group1, $GUI_SHOW)
  37.                         GUICtrlSetState($Checkbox1, $GUI_SHOW)
  38.                         GUICtrlSetState($Group2, $GUI_HIDE)
  39.                         GUICtrlSetState($Checkbox2, $GUI_HIDE)
  40.                         GUICtrlSetState($Group3, $GUI_HIDE)
  41.                         GUICtrlSetState($Checkbox3, $GUI_HIDE)
  42.                         GUICtrlSetState($Checkbox1, $GUI_CHECKED)
  43.                 Case $Radio2
  44.                        
  45.                         GUICtrlSetState($Group2, $GUI_SHOW)
  46.                         GUICtrlSetState($Checkbox2, $GUI_SHOW)
  47.                         GUICtrlSetState($Group1, $GUI_HIDE)
  48.                         GUICtrlSetState($Checkbox1, $GUI_HIDE)
  49.                         GUICtrlSetState($Group3, $GUI_HIDE)
  50.                         GUICtrlSetState($Checkbox3, $GUI_HIDE)
  51.                         GUICtrlSetState($Checkbox2, $GUI_CHECKED)
  52.                 Case $Radio3
  53.                        
  54.                         GUICtrlSetState($Group3, $GUI_SHOW)
  55.                         GUICtrlSetState($Checkbox3, $GUI_SHOW)
  56.                         GUICtrlSetState($Group1, $GUI_HIDE)
  57.                         GUICtrlSetState($Checkbox1, $GUI_HIDE)
  58.                         GUICtrlSetState($Group2, $GUI_HIDE)
  59.                         GUICtrlSetState($Checkbox2, $GUI_HIDE)
  60.                         GUICtrlSetState($Checkbox3, $GUI_CHECKED)
  61.                 Case $Radio4
  62.                        
  63.                         GUICtrlSetState($Group1, $GUI_HIDE)
  64.                         GUICtrlSetState($Checkbox1, $GUI_HIDE)
  65.                         GUICtrlSetState($Group2, $GUI_HIDE)
  66.                         GUICtrlSetState($Checkbox2, $GUI_HIDE)
  67.                         GUICtrlSetState($Group3, $GUI_HIDE)
  68.                         GUICtrlSetState($Checkbox3, $GUI_HIDE)
  69.                        
  70.         EndSwitch
  71. WEnd
复制代码
 楼主| 发表于 2015-6-24 13:38:35 | 显示全部楼层
回复 3# dnvplj


    Hi Dnvplj, Problem fixed, thanks.
 楼主| 发表于 2015-6-24 13:39:25 | 显示全部楼层
回复 2# hnfeng


    hi Hnfeng,

It's enough for me, thanks for your help!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2026-9-21 07:39 , Processed in 0.085310 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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