faceyao 发表于 2009-6-30 01:10:56

新手,关于GUI

本帖最后由 faceyao 于 2009-6-30 12:14 编辑

请问想要按下按钮1则弹出“早上好”,按下按钮2则弹出“下午好”,请问代码该加到哪里?
把msgbox(0,"","早上好")和msgbox(0,"","下午好")加在哪个位置?#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 492, 291, 232, 168)
$Button1 = GUICtrlCreateButton("Button1", 176, 72, 107, 41, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button1", 178, 193, 107, 41, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

                Case $Button1
        EndSwitch
WEnd

wuluck 发表于 2009-6-30 02:06:07

如果格式没错就是
Case $Button1
msgbox(0,"","早上好")
Case $Button2
msgbox(0,"","下午好")

faceyao 发表于 2009-6-30 11:54:30

2# wuluck #include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 492, 291, 232, 168)

$Button1 = GUICtrlCreateButton("Button1", 176, 72, 107, 41, $WS_GROUP)

$Button2 = GUICtrlCreateButton("Button1", 178, 193, 107, 41, $WS_GROUP)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

Case $Button1
msgbox(0,"","早上好")
Case $Button2
msgbox(0,"","下午好")



While 1

      $nMsg = GUIGetMsg()

      Switch $nMsg

                Case $GUI_EVENT_CLOSE

                        Exit



                Case $Button1

      EndSwitch

WEnd
这样写了之后运行错误:

afan 发表于 2009-6-30 12:01:32

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

$Form1 = GUICreate("Form1", 492, 291, 232, 168)
$Button1 = GUICtrlCreateButton("Button1", 176, 72, 107, 41, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button1", 178, 193, 107, 41, $WS_GROUP)

GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        msgbox(0, "", "早上好")
                Case $Button2
                        msgbox(0, "", "下午好")
        EndSwitch
WEnd

faceyao 发表于 2009-6-30 12:13:58

谢谢,已解决
页: [1]
查看完整版本: 新手,关于GUI