找回密码
 加入
搜索
查看: 3643|回复: 13

[AU3基础] 怎么实现那两句。。。

 火..   [复制链接]
发表于 2011-5-24 12:48:22 | 显示全部楼层 |阅读模式
本帖最后由 yanjerry9133 于 2011-5-24 12:51 编辑

25,26行怎么实现
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 464, 310, 318, 156)
$Button1 = GUICtrlCreateButton("确定", 45, 192, 169, 49)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $Form2 = GUICreate("Form2", 341, 148, 304, 293,"","",$Form1)
                        $Button1 = GUICtrlCreateButton("给父窗口创建一个取消按钮", 80, 40, 169, 49)
                        GUISetState(@SW_SHOW)
                                        While 1
                                                $nMsg = GUIGetMsg()
                                                Switch $nMsg
                                                        Case $GUI_EVENT_CLOSE
                                                                Exit
                                                        Case $Button1
                                                                ;给父窗口创建一个取消按钮
                                                                ;关闭子窗口
                                                EndSwitch
                                        WEnd

        EndSwitch
WEnd

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-5-24 12:56:09 | 显示全部楼层
guictrlsetdata($Button1,"取消")
guidelete($Form2)
发表于 2011-5-24 13:36:49 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>

Global $Add_Button = 1000
Global $nMsg
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 464, 310, 318, 156)
$Button1 = GUICtrlCreateButton("确定", 45, 192, 169, 49)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
While 1
        $nMsg = GUIGetMsg()
        Select
                Case $nMsg = $GUI_EVENT_CLOSE
                        Exit
                Case $nMsg = $Button1
                        $Form2 = GUICreate("Form2", 341, 148, 304, 293, -1, -1, $Form1)
                        $Button1_1 = GUICtrlCreateButton("给父窗口创建一个取消按钮", 80, 40, 169, 49)
                        GUISetState(@SW_SHOW)
                        While 1
                                $nMsg1 = GUIGetMsg(1)
                                If $nMsg1[1] = $Form2 Then
                                        Switch $nMsg1[0]
                                                Case $GUI_EVENT_CLOSE
                                                        Exit
                                                Case $Button1_1
                                                        if Not IsHWnd($Add_Button) then $Add_Button = _GUICtrlButton_Create($Form1, "新增加的按钮", 45, 92, 169, 49)
                                                        $nMsg = GUIGetMsg()
                                                        GUIDelete($Form2)
                                                        ExitLoop
                                        EndSwitch
                                EndIf
                        WEnd
        EndSelect
WEnd


Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
        #forceref $hWnd, $Msg
        Local $nNotifyCode = BitShift($wParam, 16)
        Local $nID = BitAND($wParam, 0x0000FFFF)
        Local $hCtrl = $lParam
        Local $sText = ""

        Switch $hCtrl
                Case $Add_Button
                        Switch $nNotifyCode
                                Case $BN_CLICKED
                                        msgbox(0,0,"这是新增加的按钮")
                        EndSwitch
                        Return $GUI_RUNDEFMSG
        EndSwitch
EndFunc   ;==>WM_COMMAND

评分

参与人数 1贡献 +10 收起 理由
tryhi + 10

查看全部评分

发表于 2011-5-24 13:38:39 | 显示全部楼层
在创建主GUI时一起创建好这个按钮,设为隐藏或者将坐标设在gui外面,这样就看不到了,然后在需要是再显示或移动过来
发表于 2011-5-24 14:24:48 | 显示全部楼层
学习气氛很浓烈
 楼主| 发表于 2011-5-24 21:37:24 | 显示全部楼层
回复 3# 3mile

先谢谢大家了,
Global $add_button=1000;为什么是1000
下面那个函数看着有些吃力。。。
发表于 2011-5-25 09:47:26 | 显示全部楼层
3smile  不错  高手就是高手
 楼主| 发表于 2011-5-25 10:27:57 | 显示全部楼层
回复 3# 3mile
如果要在你的30行调用一个函数来给form1增加按钮,那一部分又该怎么写,我试了一下,没成功。。。
Func _addBotton()
        $Add_Button=GUICtrlCreateButton("新增加的按钮",45,92,169,49)
EndFunc
发表于 2011-5-26 20:45:37 | 显示全部楼层
3mile的代码中添加按钮用的是_GUICtrlButton_Create($Form1, "新增加的按钮", 45, 92, 169, 49)
这个可以指定GUI窗体,而GUICtrlCreateButton只能创建按钮到最近一次创建的GUI窗体上
发表于 2011-5-27 08:13:18 | 显示全部楼层
回复 9# 飘云
谁说的,切换下操作界面就行了,用guiswitch
发表于 2011-5-27 14:08:55 | 显示全部楼层
回复 10# netegg


    原来如此,还可以用这个函数来指定最近一次窗口,一直没注意过,我建GUI一般都是事先先建完所有控件再操作的
发表于 2011-5-27 14:49:21 | 显示全部楼层
3笑的代码出神入化噢
发表于 2011-6-6 20:21:01 | 显示全部楼层
回复 10# netegg


    如果是用这个函数新建到一个存在的窗体(比如说一个已经打开的EXCEL文件中),那么如果响应操作呢??
发表于 2011-6-6 21:23:22 | 显示全部楼层
操作只对当前活动的界面有效,除非是另外操作
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-19 12:35 , Processed in 0.092974 second(s), 29 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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