Что нового

[Окна, Диалоги] Закрыть 2ое окно не закрывая основную програму

Foli

Знающий
Сообщения
39
Репутация
5
Помогите нужно при нажатие на $Button2 закрывать $Form2


Код:
global $Button2
#Region ### START Koda GUI section ### Form=

;создали основное окно и кнопку
$Form2 = GUICreate("Form2", 413, 300, 302, 218)
$Button1 = GUICtrlCreateButton("Button1", 136, 104, 145, 73, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


Func win()
	;написали функцию создающую форму и кнопку которая должна его закрыть "Forma2"
$Form2 = GUICreate("Form2", 413, 300, 302, 218)
$Button2 = GUICtrlCreateButton("Button2", 136, 104, 145, 73, $WS_GROUP)
GUISetState(@SW_SHOW)
EndFunc
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
        Case $Button1
		win()
	Case $Button2
		;какой оператор применить ума не прилажу прибывал winclose но он закрывает все формы
	EndSwitch
WEnd
 

axlwor

Скриптер
Сообщения
657
Репутация
147
ну тогда уж не стоит КАЖДЫЙ раз создавать форуму form2. будет достаточно hide/show
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,322
Foli,
Код:
$hForm = GUICreate("Form", 413, 300)
$nButton1 = GUICtrlCreateButton("Button1", 136, 104, 145, 73)
GUISetState()
While 1
	Switch GUIGetMsg()
		Case -3
			Exit
		Case $nButton1
			win()
	EndSwitch
WEnd

Func win()
	$hForm2 = GUICreate("Form2", 300, 200, -1, -1, $hForm)
	$nButton2 = GUICtrlCreateButton("Button2", 100, 50, 100, 50)
	GUISetState()
	While 1
		Switch GUIGetMsg()
			Case -3, $nButton2
				ExitLoop
		EndSwitch
	WEnd
	GUIDelete($hForm2)
EndFunc   ;==>win

Или
Код:
$hForm = GUICreate("Form", 413, 300)
$nButton1 = GUICtrlCreateButton("Button1", 136, 104, 145, 73)

$hForm2 = GUICreate("Form2", 300, 200, -1, -1, $hForm)
$nButton2 = GUICtrlCreateButton("Button2", 100, 50, 100, 50)
GUISetState(@SW_SHOW, $hForm)
While 1
	$aMsg = GUIGetMsg(1)
	Switch $aMsg[1]
		Case $hForm
			Switch $aMsg[0]
				Case -3
					Exit
				Case $nButton1
					GUISetState(@SW_SHOW, $hForm2)
			EndSwitch
		Case $hForm2
			Switch $aMsg[0]
				Case -3, $nButton2
					GUISetState(@SW_HIDE, $hForm2)
			EndSwitch
	EndSwitch
WEnd
 
Автор
F

Foli

Знающий
Сообщения
39
Репутация
5
:laugh:Спс, ответ дан, тему можно закрыть.
 
Верх