Цитата:
Цитата eus_deus
надо, чтобы второе окно появлялось по необходимости при нажатии на кнопку »
|
Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$hForm1 = GUICreate('Form1', 300, 200, 100, 100)
$iShowForm2_Bttn = GUICtrlCreateButton('Show Form2', 20, 170, 90, 20)
$aForm1_Elements = _FormElements($hForm1)
$hForm2 = GUICreate('Form2', 300, 200, 450, 100)
$aForm2_Elements = _FormElements($hForm2)
GUISetState(@SW_SHOW, $hForm1)
While 1
$aMsg = GUIGetMsg(1)
Switch $aMsg[0]
Case $GUI_EVENT_CLOSE
If $aMsg[1] = $hForm1 Then
Exit
Else
ContinueCase ;To trigger next state
EndIf
Case $iShowForm2_Bttn
If GUICtrlRead($iShowForm2_Bttn) = 'Show Form2' Then
GUICtrlSetData($iShowForm2_Bttn, 'Hide Form2')
GUISetState(@SW_SHOW, $hForm2)
Else
GUICtrlSetData($iShowForm2_Bttn, 'Show Form2')
GUISetState(@SW_HIDE, $hForm2)
EndIf
Case $aForm1_Elements[1] To $aForm1_Elements[$aForm1_Elements[0]]
MsgBox(64, 'Event', 'Event from element (' & GUICtrlRead($aMsg[0], 1) & ') in form 1', 0, $hForm1)
Case $aForm2_Elements[1] To $aForm2_Elements[$aForm2_Elements[0]]
MsgBox(64, 'Event', 'Event from element (' & GUICtrlRead($aMsg[0], 1) & ') in form 2', 0, $hForm2)
EndSwitch
WEnd
Func _FormElements($hForm)
GUISwitch($hForm)
Local $aRet[3] = [2]
$aRet[1] = GUICtrlCreateButton('Button1', 20, 20, 60, 20)
$aRet[2] = GUICtrlCreateButton('Button2', 20, 40, 60, 20)
Return $aRet
EndFunc
|