找回密码
 加入
搜索
查看: 4545|回复: 9

[系统综合] CASE 中能否将两个按钮的动作写在一起??[已解决]

  [复制链接]
发表于 2011-5-15 01:45:02 | 显示全部楼层 |阅读模式
本帖最后由 木头人 于 2011-5-16 00:12 编辑

例如这样
Case $TButton1, $TButton2
如果可以的话,接下来如何判断点击的是$TButton1或$TButton2 呢
If GUICtrlCreateButton($TButton1) = 1 Then
似乎是错误的。
发表于 2011-5-15 01:54:32 | 显示全部楼层
当然可以 了
如何判断,当然还是根据你case是啥判断的,比如你是采用的事件模式


Opt("GUIOnEventMode", 1)
Local $OKButton[10]
$hwd = GUICreate("Config", 280, 230)
GUISetOnEvent(-3, "_Event")
 
For $i = 0 To 9
        $OKButton[$i] = GUICtrlCreateButton("OK" & $i + 1, 50, $i * 20, 50, 20)
        GUICtrlSetOnEvent(-1, "_Event")
        Assign($OKButton[$i], $i + 1)
Next

GUICtrlSetOnEvent(-1, "_Event")
GUISetState()
 
While 1
        Sleep(100)
WEnd
 
Func _Event()
        Switch @GUI_CtrlId
                Case -3
                        Exit
                Case $OKButton[0] To $OKButton[UBound($OKButton) - 1]
                        MsgBox(0, "pressed", "Pressed OK Button" & Eval(@GUI_CtrlId))
        EndSwitch
EndFunc

发表于 2011-5-15 02:04:20 | 显示全部楼层
消息模式:

Local $OKButton[10], $msg
$hwd = GUICreate("Config", 280, 230)
 
For $i = 0 To 9
        $OKButton[$i] = GUICtrlCreateButton("OK" & $i, 50, $i * 20, 50, 20)
Next

GUISetState()
 
While True
        $msg = GUIGetMsg()
        Switch $msg
                Case -3
                        Exit
                Case $OKButton[0] To $OKButton[UBound($OKButton) - 1]
                        MsgBox(0, "pressed", "Pressed OK Button" & $msg - 3)
        EndSwitch        
        Sleep(10)
WEnd
 
发表于 2011-5-15 03:14:32 | 显示全部楼层
回复 1# 木头人
Case $TButton1, $TButton2
        If $TButton1 Then 
        Else
        EndIf
发表于 2011-5-15 10:58:57 | 显示全部楼层
回复 2# happytc
看着眼熟
发表于 2011-5-15 11:06:46 | 显示全部楼层
回复 4# netegg


    蛋蛋的代码很简洁,赞一个~
 楼主| 发表于 2011-5-15 22:53:00 | 显示全部楼层
回复 4# netegg

回复蛋蛋,试了这个代码不行。
 楼主| 发表于 2011-5-15 22:56:15 | 显示全部楼层
回复 3# happytc

谢谢,是可以实现,但是看不懂。
实际些的是有个按钮 TButton1及 tButton2,已经设置 好了
CASE $Tbutton1, $tButton2
接下来应该如何判断点击的是tButton2,或tButton1 呢
发表于 2011-5-15 23:11:16 | 显示全部楼层
本帖最后由 netegg 于 2011-5-15 23:18 编辑

回复 8# 木头人

switch $msg
  case $tbutton1, $tbutton2
     if $msg = $tbutton1 then
          msgbox(0,0,1)
     else
           msgbox(0,0,2)
    endif
endswitch

试试看,或者索性用select
select
  case  $msg = $tbutton1
          msgbox(0,0,1)
  case  $msg = $tbutton2
           msgbox(0,0,2)
endselect

评分

参与人数 1金钱 +20 收起 理由
木头人 + 20 谢谢

查看全部评分

 楼主| 发表于 2011-5-16 00:11:11 | 显示全部楼层
谢谢蛋蛋,已经解决
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-21 16:14 , Processed in 0.080672 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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