qingting 发表于 2009-3-25 11:59:57

程序中动态新建的按钮,如何在gui中被选中

程序中动态新建的按钮,如何在gui中被选中
如:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <user_function.au3>
#Region ### START Koda GUI section ### Form=D:\auto_check_up\Form2.kxf

$Form1 = GUICreate("自动检测文件配置工具", 555, 277, 192, 124)

Dim $TabSheet,$Label_se,$Label_se_dir,$Button_se,$Label_de,$Label_de_dir,$Button_de,$Label_url,$In_url
$Tab1 = GUICtrlCreateTab(24, 32, 513, 185)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet = GUICtrlCreateTabItem("第1页")
$Label_se = GUICtrlCreateLabel("源数据目录:", 40, 80, 90, 17)
$Label_se_dir = GUICtrlCreateLabel("", 138, 80, 314, 17)
$Button_se = GUICtrlCreateButton("dir", 464, 80, 33, 17, $WS_GROUP)
$Label_de = GUICtrlCreateLabel("目的数据目录:", 40, 120, 90, 17)
$Label_de_dir = GUICtrlCreateLabel("", 138, 120, 314, 17)
$Button_de = GUICtrlCreateButton("dir", 464, 120, 33, 17, $WS_GROUP)
$Label_url = GUICtrlCreateLabel("导入程序url:", 40, 160, 90, 17)
$In_url = GUICtrlCreateInput("", 138, 160, 375, 21)
GUICtrlCreateTabItem("")
$Button1 = GUICtrlCreateButton("保存", 344, 232, 89, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("退出", 448, 232, 81, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("+++", 416, 32, 41, 17, $WS_GROUP)
$Button4 = GUICtrlCreateButton("---", 472, 32, 41, 17, $WS_GROUP)
$In_sec = GUICtrlCreateInput("", 160, 232, 65, 21)
$Label5 = GUICtrlCreateLabel("监测时间间隔(秒):", 32, 232, 113, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
        Case $GUI_EVENT_CLOSE
        Case $Button2
        Exit
        Case $Button3
        ;$TabSheet,$Label_se,$Label_se_dir,$Button_se,$Label_de,$Label_de_dir,$Button_de,$Label_url,$In_url
                ReDim $TabSheet
                ReDim $Label_se
                ReDim $Label_se_dir
                ReDim $Button_se               
                ReDim $Label_de
                ReDim $Label_de_dir
                ReDim $Button_de
                ReDim $Label_url
                ReDim $In_url

                        $TabSheet = GUICtrlCreateTabItem("第"&UBound($TabSheet)&"页")
                        $Label_se = GUICtrlCreateLabel("源数据目录:", 40, 80, 90, 17)
                        $Label_se_dir = GUICtrlCreateLabel("", 138, 80, 314, 17)
                        $Button_se = GUICtrlCreateButton("dir", 464, 80, 33, 17, $WS_GROUP)
                        $Label_de = GUICtrlCreateLabel("目的数据目录:", 40, 120, 90, 17)
                        $Label_de_dir = GUICtrlCreateLabel("", 138, 120, 314, 17)
                        $Button_de = GUICtrlCreateButton("dir", 464, 120, 33, 17, $WS_GROUP)
                        $Label_url = GUICtrlCreateLabel("导入程序url:", 40, 160, 90, 17)
                        $In_url = GUICtrlCreateInput("", 138, 160, 375, 21)

        Case $Button_se
                        $msg=_FileSelectFolder("源目录")
                        GUICtrlSetData($Label_se_dir,$msg)
        Case $Button_de
                        $msg=_FileSelectFolder("目标目录")
                        GUICtrlSetData($Label_de_dir,$msg)
EndSwitch
WEnd

case $button_se
???
怎么增加?

[ 本帖最后由 qingting 于 2009-4-9 12:07 编辑 ]

liongodmien 发表于 2009-3-25 14:52:52

case $button_se to$Button_se
    for $i = 0 to UBound($TabSheet) - 1
      if $msg = $button_se[$i] then ...............
    next

大绯狼 发表于 2009-3-25 16:11:01

经典的CASE TO。。。。

qingting 发表于 2009-3-26 08:39:04

谢谢。已经成功。

但是奇怪怎么动态建立的控件,第一次怎么没有实际效果,需要多点了几次

liongodmien 发表于 2009-3-26 11:32:52

原帖由 qingting 于 2009-3-26 08:39 发表 http://www.autoitx.com/images/common/back.gif
谢谢。已经成功。

但是奇怪怎么动态建立的控件,第一次怎么没有实际效果,需要多点了几次

因为这里用到 CASE XXXXX TO XXXXXX 的中间有非当前想触发的控件值,造成了一些奇怪的情况
页: [1]
查看完整版本: 程序中动态新建的按钮,如何在gui中被选中