Search the Community
Showing results for tags 'hide/show'.
-
Hello forum, I want to create a program with multiple menus and many elements inside. The problem is my way of doing this and below I have an example of how I do these menus. I know it's a bad way of doing them as using this method for more elements and menus cause big flickering. Can someone please help me with some tips of optimizing this or tell me another way of creating that menus with many elements without cause flickering? From a long time ago I still try to solve this but without any results, just small improvements. Many thanks for everyone. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $MENU_HOVER = '' Global $MENU_SELECTED = '' Global $COLOR_STANDARD = 0x94A5E9 Global $COLOR_HOVER = 0x8292d1 Global $COLOR_SELECTED = 0x7584bf $MENU = GUICreate("Menu", 615, 437, -1, -1, -1, -1, 0) GUISetFont(10, 400, 0, "Arial") $MENU_1 = GUICtrlCreateLabel("Menu 1", 8, 24, 106, 28, BitOR($SS_CENTER, $SS_CENTERIMAGE)) $MENU_2 = GUICtrlCreateLabel("Menu 2", 8, 56, 106, 28, BitOR($SS_CENTER, $SS_CENTERIMAGE)) $MENU_3 = GUICtrlCreateLabel("Menu 3", 8, 88, 106, 28, BitOR($SS_CENTER, $SS_CENTERIMAGE)) ;MENU 1 ELEMENTS $MENU_1_ELEMENT_1 = GUICtrlCreateButton("Menu1 Button", 128, 24, 147, 25) ;MENU 2 ELEMENTS $MENU_2_ELEMENT_1 = GUICtrlCreateButton("Menu2 Button", 128, 24, 147, 25) $MENU_2_ELEMENT_2 = GUICtrlCreateLabel("Another element", 128, 64, 99, 20) _Design() _Hide_All() GUISetState(@SW_SHOW, $MENU) While 1 $Cursor = GUIGetCursorInfo($MENU) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MENU_1 _Previous_Selected_Cancel() $MENU_SELECTED = 'Menu1' GUICtrlSetBkColor($MENU_1, $COLOR_SELECTED) _Show('Menu1') Case $MENU_2 _Previous_Selected_Cancel() $MENU_SELECTED = 'Menu2' GUICtrlSetBkColor($MENU_2, $COLOR_SELECTED) _Show('Menu2') Case $MENU_3 _Previous_Selected_Cancel() $MENU_SELECTED = 'Menu3' GUICtrlSetBkColor($MENU_3, $COLOR_SELECTED) _Show('Menu3') EndSwitch If $Cursor[4] = $MENU_1 Then If $MENU_HOVER <> 'Menu1' And $MENU_SELECTED <> 'Menu1' Then _Previous_Hover_Cancel() GUICtrlSetBkColor($MENU_1, $COLOR_HOVER) $MENU_HOVER = 'Menu1' EndIf ElseIf $Cursor[4] = $MENU_2 Then If $MENU_HOVER <> 'Menu2' And $MENU_SELECTED <> 'Menu2' Then _Previous_Hover_Cancel() GUICtrlSetBkColor($MENU_2, $COLOR_HOVER) $MENU_HOVER = 'Menu2' EndIf ElseIf $Cursor[4] = $MENU_3 Then If $MENU_HOVER <> 'Menu3' And $MENU_SELECTED <> 'Menu3' Then _Previous_Hover_Cancel() GUICtrlSetBkColor($MENU_3, $COLOR_HOVER) $MENU_HOVER = 'Menu3' EndIf Else _Previous_Hover_Cancel() $MENU_HOVER = 'Idle' EndIf WEnd Func _Design() GUICtrlSetColor($MENU_1, 0xFFFFFF) GUICtrlSetBkColor($MENU_1, $COLOR_STANDARD) GUICtrlSetCursor($MENU_1, 0) GUICtrlSetColor($MENU_2, 0xFFFFFF) GUICtrlSetBkColor($MENU_2, $COLOR_STANDARD) GUICtrlSetCursor($MENU_2, 0) GUICtrlSetColor($MENU_3, 0xFFFFFF) GUICtrlSetBkColor($MENU_3, $COLOR_STANDARD) GUICtrlSetCursor($MENU_3, 0) EndFunc ;==>_Design Func _Hide_All() GUICtrlSetState($MENU_1_ELEMENT_1, $GUI_HIDE) GUICtrlSetState($MENU_2_ELEMENT_1, $GUI_HIDE) GUICtrlSetState($MENU_2_ELEMENT_2, $GUI_HIDE) EndFunc ;==>_Hide_All Func _Show($MENU_SHOW) _Hide_All() If $MENU_SHOW = 'Menu1' Then GUICtrlSetState($MENU_1_ELEMENT_1, $GUI_SHOW) ElseIf $MENU_SHOW = 'Menu2' Then GUICtrlSetState($MENU_2_ELEMENT_1, $GUI_SHOW) GUICtrlSetState($MENU_2_ELEMENT_2, $GUI_SHOW) ElseIf $MENU_SHOW = 'Menu3' Then EndIf EndFunc ;==>_Show Func _Previous_Hover_Cancel() If $MENU_HOVER = 'Menu1' Then If $MENU_SELECTED <> 'Menu1' Then GUICtrlSetBkColor($MENU_1, $COLOR_STANDARD) ElseIf $MENU_HOVER = 'Menu2' Then If $MENU_SELECTED <> 'Menu2' Then GUICtrlSetBkColor($MENU_2, $COLOR_STANDARD) ElseIf $MENU_HOVER = 'Menu3' Then If $MENU_SELECTED <> 'Menu3' Then GUICtrlSetBkColor($MENU_3, $COLOR_STANDARD) EndIf EndFunc ;==>_Previous_Hover_Cancel Func _Previous_Selected_Cancel() If $MENU_SELECTED = 'Menu1' Then GUICtrlSetBkColor($MENU_1, $COLOR_STANDARD) If $MENU_SELECTED = 'Menu2' Then GUICtrlSetBkColor($MENU_2, $COLOR_STANDARD) If $MENU_SELECTED = 'Menu3' Then GUICtrlSetBkColor($MENU_3, $COLOR_STANDARD) EndFunc ;==>_Previous_Selected_Cancel