请教如何在点击Button的同时关闭主窗口
请教如何在点击Button的同时关闭主窗口:下面的代码中,点击按钮1或者其他两个按钮,关闭主窗口form1,然后出现MsgBox的提示消息?
搞了半天没整明白,希望各位大大帮助下俺这个新人#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#Include <GuiImageList.au3>
#Include <GuiButton.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("form1", 688, 201, -1, -1,Bitor($WS_CAPTION,$WS_SYSMENU))
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\banner.jpg", 0, 0, 687, 93)
$Button1 = GUICtrlCreateButton("按钮1", 400, 109, 75, 75 )
_GUICtrlButton_SetImageList($Button1, _GetImageListHandle("shell32.dll",-20, True),2,-1,12)
$Button2 = GUICtrlCreateButton("按钮2", 500, 109, 75, 75 )
_GUICtrlButton_SetImageList($Button2, _GetImageListHandle("shell32.dll",-279, True),2,-1,12)
$Button3 = GUICtrlCreateButton("按钮3", 600, 109, 75, 75 )
_GUICtrlButton_SetImageList($Button3, _GetImageListHandle("shell32.dll",-258, True),2,-1,12)
$Label1 = GUICtrlCreateLabel(" ★ 说明事项:" & @LF & "" & @LF & " ★ 待添加" & @LF & "" & @LF & " ★ 待添加", 0, 112, 350, 65)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0, 0, "我是按扭")
Case $Button2
MsgBox(0, 0, "我是按扭")
Case $Button3
MsgBox(0, 0, "我是按扭")
EndSwitch
WEnd
Func _GetImageListHandle($sFile, $nIconID = 0, $fLarge = False)
Local $iSize = 16
If $fLarge Then $iSize = 32
Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
_GUIImageList_AddBitmap($hImage, $sFile)
Else
_GUIImageList_AddIcon($hImage, $sFile, $nIconID, $fLarge)
EndIf
Return $hImage
EndFunc ;==>_GetImageListHandle #NoTrayIcon
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#Include <GuiImageList.au3>
#Include <GuiButton.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("form1", 688, 201, -1, -1,Bitor($WS_CAPTION,$WS_SYSMENU))
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\banner.jpg", 0, 0, 687, 93)
$Button1 = GUICtrlCreateButton("按钮1", 400, 109, 75, 75 )
_GUICtrlButton_SetImageList($Button1, _GetImageListHandle("shell32.dll",-20, True),2,-1,12)
$Button2 = GUICtrlCreateButton("按钮2", 500, 109, 75, 75 )
_GUICtrlButton_SetImageList($Button2, _GetImageListHandle("shell32.dll",-279, True),2,-1,12)
$Button3 = GUICtrlCreateButton("按钮3", 600, 109, 75, 75 )
_GUICtrlButton_SetImageList($Button3, _GetImageListHandle("shell32.dll",-258, True),2,-1,12)
$Label1 = GUICtrlCreateLabel(" ★ 说明事项:" & @LF & "" & @LF & " ★ 待添加" & @LF & "" & @LF & " ★ 待添加", 0, 112, 350, 65)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUIDelete($Form1)
MsgBox(0, 0, "没了主窗体,只能在进程管理器中结束了")
Case $Button2
MsgBox(0, 0, "我是按扭")
Case $Button3
MsgBox(0, 0, "我是按扭")
EndSwitch
WEnd
Func _GetImageListHandle($sFile, $nIconID = 0, $fLarge = False)
Local $iSize = 16
If $fLarge Then $iSize = 32
Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
_GUIImageList_AddBitmap($hImage, $sFile)
Else
_GUIImageList_AddIcon($hImage, $sFile, $nIconID, $fLarge)
EndIf
Return $hImage
EndFunc ;==>_GetImageListHandle 首先感谢,但是实际还没有达到我想要的
GUISetState(@SW_HIDE, $Form1)或者GUIDelete($Form1)都不能结束主窗体的进程,都只能在任务管理器中结束...这点比较郁闷,不知道有更好的办法没有 本帖最后由 xyold1 于 2011-3-10 16:13 编辑
主窗体的进程是脚本的进程,若将其结束,相当于点了关闭按钮,那么整个脚本也就over了
要是想这样,那么GUIDelete($Form1)后,再msgbox再exit 是的,所以一直找帮助也没找到办法,目前我就是用的GUIDelete($Form1)和exit
再次感谢,希望能有更好的解决办法 good example....
页:
[1]