Что нового

[Элементы GUI] скрыть\восстановить элемент gui

andreitrane

Новичок
Сообщения
141
Репутация
3
хочу чтобы при нажатии кнопку скрывалась одна group, и появлялась другая
да, получилось, но почему то остальные элементы group вместе с ней не исчезли... они же вроде идут вместе с группой
это что, надо сделать чтобы при нажатии на кнопку на каждый элемент ставился атрибут $gui_hide/$gui_show?
Код:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 405, 294, 250, 212)
$Group1 = GUICtrlCreateGroup("олол!", 8, 16, 129, 97)
GUICtrlSetState(-1, $GUI_HIDE)
$Combo1 = GUICtrlCreateCombo("Combo1", 16, 40, 113, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("олол2", 8, 16, 129, 97)
$Edit1 = GUICtrlCreateEdit("", 16, 32, 113, 73)
GUICtrlSetData(-1, "Edit1")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Button1", 16, 120, 113, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$fl = 1

While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			if $fl = 1 Then
			GUICtrlSetState($Group2, $GUI_HIDE)
			GUICtrlSetState($Group1, $GUI_SHOW)
			$fl = 0
			ElseIf $fl = 0 Then
			GUICtrlSetState($Group2, $GUI_SHOW)
			GUICtrlSetState($Group1, $GUI_HIDE)
			$fl = 1
			EndIf

	EndSwitch
WEnd
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
andreitrane [?]
это что, надо сделать чтобы при нажатии на кнопку на каждый элемент ставился атрибут $gui_hide/$gui_show?
Да.
Вот так примерно:

Код:
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form2 = GUICreate("Form2", 405, 294, 250, 212)

$nGroup1_StartCtrl = GUICtrlCreateDummy()
GUICtrlCreateGroup("олол!", 8, 16, 129, 97)
$Combo1 = GUICtrlCreateCombo("Combo1", 16, 40, 113, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$nGroup1_EndCtrl = GUICtrlCreateDummy()

$nGroup2_StartCtrl = GUICtrlCreateDummy()
$Group2 = GUICtrlCreateGroup("олол2", 8, 16, 129, 97)
$Edit2 = GUICtrlCreateEdit("", 16, 32, 113, 73)
GUICtrlSetData(-1, "Edit1")
$nGroup2_EndCtrl = GUICtrlCreateDummy()

$Button1 = GUICtrlCreateButton("Button1", 16, 120, 113, 41)

For $iCtrlID = $nGroup1_StartCtrl To $nGroup1_EndCtrl
	GUICtrlSetState($iCtrlID, $GUI_HIDE)
Next

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
			$nShow_StartCtrl = $nGroup1_StartCtrl
			$nShow_EndCtrl = $nGroup1_EndCtrl
			$nHide_StartCtrl = $nGroup2_StartCtrl
			$nHide_EndCtrl = $nGroup2_EndCtrl
			
			If BitAND(GUICtrlGetState($nGroup1_StartCtrl), $GUI_SHOW) Then
				$nShow_StartCtrl = $nGroup2_StartCtrl
				$nShow_EndCtrl = $nGroup2_EndCtrl
				$nHide_StartCtrl = $nGroup1_StartCtrl
				$nHide_EndCtrl = $nGroup1_EndCtrl
			EndIf
			
			For $iCtrlID = $nShow_StartCtrl To $nShow_EndCtrl
				GUICtrlSetState($iCtrlID, $GUI_SHOW)
			Next
			
			For $iCtrlID = $nHide_StartCtrl To $nHide_EndCtrl
				GUICtrlSetState($iCtrlID, $GUI_HIDE)
			Next
    EndSwitch
WEnd
 
Верх