bingxinchi 发表于 2010-5-21 20:26:53

GUI内的多个按钮怎么实现做同一个动作..

本帖最后由 bingxinchi 于 2010-5-21 21:24 编辑

一、GUI内的多个按钮怎么实现做同一个动作

二、函数 1 =函数2 = 函数3 =函数4 =函数N 的表达式该怎么写

谢谢指教额...在线等

水木子 发表于 2010-5-21 20:31:33

本帖最后由 水木子 于 2010-5-21 20:44 编辑

首先建议楼主修改下提问标题,当前的标题不便于搜索。
问题二什么意思不太明白,望进一步说明。

问题一$hGUI = GUICreate('', 200, 300)
Local $aButton
For $i = 0 To 5
        $aButton[$i] = GUICtrlCreateButton("Button " & ($i + 1), 50, $i * 45 + 10, 80, 30)
Next
GUISetState()

While 1
        $iMsg = GUIGetMsg()
        Switch $iMsg
                Case - 3
                        Exit
                Case $aButton To $aButton
                        UDF()
        EndSwitch
WEnd

Func UDF()
        MsgBox(0, '', '')
EndFunc       

lanfengc 发表于 2010-5-21 20:35:48

多个按钮执行一个事件。
$button1=guictrlcreatebutton(......)
$button2=guictrlcreatebutton(......)
$button3=guictrlcreatebutton(......)
......
$buttonN=guictrlcreatebutton(......)
......

while 1
$nmsg=guigetmsg()
switch $nmsg
   case $GUI_EVENT_CLOSE
         exit
   case $button1
          function()
   case $button2
          function()
   case $button3
          function()
.......
   case $buttonN
          function()
endswitch
wen
函数 1 =函数2 = 函数3 =函数4 =函数N
从这句,我的理解是 ,你的所有函数都有返回值,你可以直接用
if 函数1 =函数2 and 函数2= 函数3 and 函数3 =函数4 and .... and 函数N-1 =函数N then
   ;做点什么?
endif
这样的方式来解决。

bingxinchi 发表于 2010-5-21 21:22:23

恩...3楼大虾说的是对的

这些函数都有返回值

返回值 1或是2

我需要的就是把 所有读取出来的函数拿来统一对比到底是1还是2

if $bxwl = $1 and = $2 and = $3 and = $4 then

endif

这样对吗?

lanfengc 发表于 2010-5-21 22:11:22

if $bxwl = $1 and$bxwl = $2 and$bxwl = $3 and$bxwl = $4 then

endif
IF判断的格式是   :
if 变量/函数([参数]) 逻辑运算符(=,>,<,<>) 常量值 then
       调用函数 或者是直接执行语句
endif
页: [1]
查看完整版本: GUI内的多个按钮怎么实现做同一个动作..