yanjerry9133 发表于 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

shenrenba 发表于 2011-5-24 12:56:09

guictrlsetdata($Button1,"取消")
guidelete($Form2)

3mile 发表于 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 = $Form2 Then
                                        Switch $nMsg1
                                                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

飘云 发表于 2011-5-24 13:38:39

在创建主GUI时一起创建好这个按钮,设为隐藏或者将坐标设在gui外面,这样就看不到了,然后在需要是再显示或移动过来

wsfda 发表于 2011-5-24 14:24:48

学习气氛很浓烈

yanjerry9133 发表于 2011-5-24 21:37:24

回复 3# 3mile

先谢谢大家了,
Global $add_button=1000;为什么是1000
下面那个函数看着有些吃力。。。

5i5wei 发表于 2011-5-25 09:47:26

3smile不错高手就是高手

yanjerry9133 发表于 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窗体上

netegg 发表于 2011-5-27 08:13:18

回复 9# 飘云
谁说的,切换下操作界面就行了,用guiswitch

飘云 发表于 2011-5-27 14:08:55

回复 10# netegg


    原来如此,还可以用这个函数来指定最近一次窗口,一直没注意过,我建GUI一般都是事先先建完所有控件再操作的

58fly 发表于 2011-5-27 14:49:21

3笑的代码出神入化噢

annybaby 发表于 2011-6-6 20:21:01

回复 10# netegg


    如果是用这个函数新建到一个存在的窗体(比如说一个已经打开的EXCEL文件中),那么如果响应操作呢??

netegg 发表于 2011-6-6 21:23:22

操作只对当前活动的界面有效,除非是另外操作
页: [1]
查看完整版本: 怎么实现那两句。。。