acbs 发表于 2010-4-20 09:34:14

[已解决]请教:GUI控件取输入内容

本帖最后由 acbs 于 2010-4-20 10:23 编辑

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("控件测试", 206, 129, 193, 115)
$Input1 = GUICtrlCreateInput("aaa", 32, 16, 153, 21)
$Input2 = GUICtrlCreateInput("bbb",32, 48, 153, 21)
$Button1 = GUICtrlCreateButton("Button1", 16, 88, 65, 25, 0)
$Button2 = GUICtrlCreateButton("Button2", 96, 88, 65, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

使用工具得到这些代码,我想点击Button1会执行一段代码,比如显示在input1中输入的内容应该怎么加代码呢?点击Button2会退出此对话框又该怎样去写呢?新手想学习一下这种格式的代码应该如何去写,请大家指点,谢谢.

guland 发表于 2010-4-20 10:05:11

回复 1# acbs #include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("控件测试", 237, 85, 450, 341)
$Input1 = GUICtrlCreateInput("aaa", 14, 14, 121, 21)
$Input2 = GUICtrlCreateInput("bbb", 14, 44, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 150, 14, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 150, 44, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        MsgBox(0,"对话框","输入框1的内容是:"&GUICtrlRead($Input1))
                Case $Button2
                        Exit
        EndSwitch
WEnd

acbs 发表于 2010-4-20 10:14:51

感谢楼上,好好学习一下.
页: [1]
查看完整版本: [已解决]请教:GUI控件取输入内容