Старожил
Сообщения: 460
Благодарности: 152
|
Профиль
|
Отправить PM
| Цитировать
Цитата morgan1991:
есть окно, внутри него второе окно, можно ли заменить второе окно на третье, а потом обратно »
|
пример:
читать дальше »
Код: 
Opt('GUIOnEventMode', 1)
Opt('MustDeclareVars', 1)
Opt('TrayIconDebug', 1)
Opt('TrayIconHide', 0)
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
HotKeySet('{ESC}', '_Pro_Exit'); Закрыть скрипт: ESC
Global $hParentWin, $hChild1Win, $hChild2Win
_Example_2()
Func _Example_1()
GUIDelete($hParentWin)
GUIDelete($hChild1Win)
GUIDelete($hChild2Win)
$hParentWin = GUICreate('Родительскоре окно', 300, 400, 100, 250)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Pro_Exit')
GUISetBkColor(0x0000ff, $hParentWin)
GUICtrlCreateButton('Пример 1', 10, 170, 150, 22)
GUICtrlSetOnEvent(-1, '_Open_Example_1')
GUICtrlCreateButton('Пример 2', 10, 170+25, 150, 22)
GUICtrlSetOnEvent(-1, '_Open_Example_2')
GUICtrlCreateButton('Сменить окно', 10, 170+25*2, 150, 22)
GUICtrlSetOnEvent(-1, '_ChangeChildWin')
$hChild1Win = GUICreate('Дочерное окно', 250, 250, 300, 300, -1, -1, $hParentWin)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Win_Close')
GUISetBkColor(0x00ff00, $hChild1Win)
$hChild2Win = GUICreate('Дочерное окно', 250, 250, 300, 300, -1, -1, $hParentWin)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Win_Close')
GUISetBkColor(0xf0ff0f, $hChild2Win)
GUISwitch($hParentWin)
GUICtrlCreateTab(10, 10, 150, 150)
GUICtrlCreateTabItem('1-1')
GUICtrlCreateTabItem('1-1')
GUISwitch($hChild1Win)
GUICtrlCreateTab(10, 10, 150, 150)
GUICtrlCreateTabItem('2-1')
GUICtrlCreateTabItem('2-1')
GUISwitch($hChild2Win)
GUICtrlCreateTab(10, 10, 150, 150)
GUICtrlCreateTabItem('3-1')
GUICtrlCreateTabItem('4-1')
GUISetState(@SW_SHOW, $hParentWin)
GUISetState(@SW_SHOW, $hChild1Win)
EndFunc
Func _Example_2()
GUIDelete($hParentWin)
GUIDelete($hChild1Win)
GUIDelete($hChild2Win)
$hParentWin = GUICreate('Родительскоре окно', 550, 400, 100, 250)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Pro_Exit')
GUISetBkColor(0x0000ff, $hParentWin)
GUICtrlCreateButton('Пример 1', 10, 170, 150, 22)
GUICtrlSetOnEvent(-1, '_Open_Example_1')
GUICtrlCreateButton('Пример 2', 10, 170+25, 150, 22)
GUICtrlSetOnEvent(-1, '_Open_Example_2')
GUICtrlCreateButton('Сменить окно', 10, 170+25*2, 150, 22)
GUICtrlSetOnEvent(-1, '_ChangeChildWin')
$hChild1Win = GUICreate('Дочерное окно', 250, 250, 200, 20, BitOR($WS_CHILD, $WS_TABSTOP), -1, $hParentWin)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Win_Close')
GUISetBkColor(0x00ff00, $hChild1Win)
$hChild2Win = GUICreate('Дочерное окно', 250, 250, 200, 20, BitOR($WS_CHILD, $WS_TABSTOP), -1, $hParentWin)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Win_Close')
GUISetBkColor(0xf0ff0f, $hChild2Win)
GUISwitch($hParentWin)
GUICtrlCreateTab(10, 10, 150, 150)
GUICtrlCreateTabItem('1-1')
GUICtrlCreateTabItem('1-1')
GUISwitch($hChild1Win)
GUICtrlCreateTab(10, 10, 150, 150)
GUICtrlCreateTabItem('2-1')
GUICtrlCreateTabItem('2-1')
GUISwitch($hChild2Win)
GUICtrlCreateTab(10, 10, 150, 150)
GUICtrlCreateTabItem('3-1')
GUICtrlCreateTabItem('4-1')
GUISetState(@SW_SHOW, $hParentWin)
GUISetState(@SW_SHOW, $hChild1Win)
EndFunc
While 1
Sleep(10)
WEnd
Func _Win_Close($hWnd='')
If NOT Eval('hWnd') Then Assign('hWnd', @GUI_WinHandle, 1)
GUIDelete($hWnd)
EndFunc
Func _Pro_Exit()
Exit
EndFunc
Func _Open_Example_1()
_Example_1()
EndFunc
Func _Open_Example_2()
_Example_2()
EndFunc
Func _ChangeChildWin()
If BitAnd(WinGetState($hChild1Win), 2) Then
GUISetState(@SW_SHOW, $hChild2Win)
GUISetState(@SW_HIDE, $hChild1Win)
Else
GUISetState(@SW_SHOW, $hChild1Win)
GUISetState(@SW_HIDE, $hChild2Win)
EndIf
EndFunc
ааааа, понял, забыл про этот вариант )
очень хороший пример!
|