Что нового

Закрытие дочернего окна

Vini

Новичок
Сообщения
27
Репутация
0
Всем доброго времени суток!
Помогите разобраться: имеется форма с кнопками, при нажатии на одну из них открывается вторая форма с одной кнопкой, при нажатии на которую должна эта форма закрыться, а первая остаться. А у меня закрываются обе форму. Поправьте меня, что я сделал не так?
Код:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Button3 = GUICtrlCreateButton("Button3", 384, 176, 75, 25)
GUISetState(@SW_SHOW)

While 1
       $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
	Switch $msg
	  		  Case $Button3
		 			About()
			
		 

EndSwitch
WEnd
Func About()
   $Form2 = GUICreate("Form2", 200, 200)
   $Button4 = GUICtrlCreateButton("Button4", 102, 176, 75, 25)
   GUISetState(@SW_SHOW)
   While 1
	$nMsg = GUIGetMsg()
		Switch $nMsg
		Case $GUI_EVENT_CLOSE
		 	exit
		 Case $Button4
			exit
		 EndSwitch
WEnd
   EndFunc
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
Код:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Button3 = GUICtrlCreateButton("Button3", 384, 176, 75, 25)
GUISetState(@SW_SHOW)

While 1
	$msg = GUIGetMsg()
	
	Switch $msg
		Case $GUI_EVENT_CLOSE
			ExitLoop
		Case $Button3
			About()
	EndSwitch
WEnd

Func About()
	$Form2 = GUICreate("Form2", 200, 200)
	$Button4 = GUICtrlCreateButton("Button4", 102, 176, 75, 25)
	GUISetState(@SW_SHOW)
	
	While 1
		$nMsg = GUIGetMsg()
		Switch $nMsg
			Case $GUI_EVENT_CLOSE, $Button4
				ExitLoop
		EndSwitch
	WEnd
	
	GUIDelete($Form2)
EndFunc


Хотя это не совсем правильно.
Как правильно создавать дочерние окна?
 
Автор
V

Vini

Новичок
Сообщения
27
Репутация
0
Мне главное, что работает. Или может подскажете как правильно будет?
Прошу прощения! Не сразу заметил ссылку! Спасибо!
 
Верх