-
AutoIt
(
http://forum.oszone.net/forumdisplay.php?f=103)
Как сделать чтобы дочернее окно при выходе не закрывало основное окно
В Autoit есть пример там дочернее окно при закрытии не закрывает основное окно, но там без кнопки а кнопку на тот пример поставить мне не удалось.
Вот пример с кнопкой, при нажатии создаётся дочернее окно а при выходе оно закрывает основное.
Как сделать так чтобы оно при закрытии не закрывало основное окно?
Код:
#include <GUIConstants.au3>
Global $2
$1 = GUICreate("1")
$But = GUICtrlCreateButton("1", 50, 50, 80, 40 , $BS_FLAT)
GUISetState ()
While 1
$iMsg = GUIGetMsg()
Select
Case $iMsg = $But
Function()
Case $iMsg = $GUI_EVENT_CLOSE
Exit
EndSelect
Wend
Func Function()
$2 = GUICreate("2", 333, 333, -1, -1, -1, -1, $1)
GUISetState()
EndFunc
|
Код:
;====================================================
;============= Example of a child window ============
;====================================================
; AutoIt version: 3.0.103
; Language: English
; Author: "SlimShady"
;
; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------
;Include constants
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
_Main()
Func _Main()
;Initialize variables
Local $GUIWidth = 250, $GUIHeight = 250
Local $ParentWin, $ParentWin_Pos, $ChildWin, $msg
;Create main/parent window
$ParentWin = GUICreate("Parent GUI", $GUIWidth, $GUIHeight)
;Save the position of the parent window
$ParentWin_Pos = WinGetPos($ParentWin, "")
;Show the parent window/Make the parent window visible
GUISetState(@SW_SHOW)
;Create child window and add the parameter to make it the child of the parent window
$ChildWin = GUICreate("Child GUI", $GUIWidth, $GUIHeight, $ParentWin_Pos[0] + 100, $ParentWin_Pos[1] + 100, -1, -1, $ParentWin)
;Show the child window/Make the child window visible
GUISetState(@SW_SHOW)
;Switch to the parent window
GUISwitch($ParentWin)
;Loop until:
;- user presses Esc when focused to the parent window
;- user presses Alt+F4 when focused to the parent window
;- user clicks the close button of the parent window
While 1
;After every loop check if the user clicked something in the GUI windows
$msg = GUIGetMsg(1)
Select
;Check if user clicked on a close button of any of the 2 windows
Case $msg[0] = $GUI_EVENT_CLOSE
;Check if user clicked on the close button of the child window
If $msg[1] = $ChildWin Then
MsgBox(64, "Test", "Child GUI will now close.")
;Switch to the child window
GUISwitch($ChildWin)
;Destroy the child GUI including the controls
GUIDelete()
;Check if user clicked on the close button of the parent window
ElseIf $msg[1] = $ParentWin Then
MsgBox(64, "Test", "Parent GUI will now close.")
;Switch to the parent window
GUISwitch($ParentWin)
;Destroy the parent GUI including the controls
GUIDelete()
;Exit the script
Exit
EndIf
EndSelect
WEnd
EndFunc ;==>_Main
|
Про этот пример я и писал
Но этот пример без кнопки
А кнопку на этот пример почему то поставить проблематично
|
assch, код нужно заключать в теги [cоde].
Цитата:
Цитата assch
Вот пример с кнопкой, при нажатии создаётся дочернее окно а при выходе оно закрывает основное.
Как сделать так чтобы оно при закрытии не закрывало основное окно? »
|
Код:
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
Global $2
$1 = GUICreate("1")
$But = GUICtrlCreateButton("1", 50, 50, 80, 40, $BS_FLAT)
GUISetState()
While 1
$nMsg = GUIGetMsg(1)
Switch $nMsg[0]
Case $But
Function()
Case $GUI_EVENT_CLOSE
If $nMsg[1] = $2 Then
GUISetState(@SW_HIDE, $2)
Else
Exit
EndIf
EndSwitch
WEnd
Func Function()
If Not IsHWnd($2) Then
$2 = GUICreate("2", 333, 333, -1, -1, -1, -1, $1)
EndIf
GUISetState(@SW_SHOW, $2)
WinActivate($2)
EndFunc
|
Цитата:
Цитата assch
Про этот пример я и писал »
|
Что то даже отдалённо не напоминает этот пример...
|
Время: 01:07.
© OSzone.net 2001-