Search the Community
Showing results for tags 'menus'.
-
I know that I'm doing something basic, and doing it wrong. I just can't seem to figure it out...I am trying to create a dynamic menu that changes when the user switches "modes." This is my code: Func _SetActions($var) $Menu_handle = _GUICtrlMenu_GetMenu($GUI_MF_BIS) _GUICtrlMenu_DeleteMenu($Menu_handle, 3) $New_Acts = _GUICtrlMenu_CreateMenu() Switch $var Case 0 _GUICtrlMenu_InsertMenuItem($New_Acts, 0, "Add", $Menu_Act_Add_Tray) _GUICtrlMenu_InsertMenuItem($New_Acts, 1, "Delete", $Menu_Act_Delete_Tray) _GUICtrlMenu_InsertMenuItem($New_Acts, 2, "Edit", $Menu_Act_Edit_Tray) _GUICtrlMenu_InsertMenuItem($New_Acts, 3, "Move", $Menu_Act_Move_Tray) Case 1 _GUICtrlMenu_InsertMenuItem($New_Acts, 0, "Add", $Menu_Act_Add_Strain) _GUICtrlMenu_InsertMenuItem($New_Acts, 1, "Delete", $Menu_Act_Delete_Strain) _GUICtrlMenu_InsertMenuItem($New_Acts, 2, "Edit", $Menu_Act_Edit_Strain) EndSwitch _GUICtrlMenu_InsertMenuItem($Menu_handle, 3, "Actions", 0, $New_Acts) _GUICtrlMenu_DrawMenuBar($GUI_MF_BIS) EndFunc I call this function with an argument of either 0 or 1. I delete the existing menu and build a new one. This part of the code works just fine, the menu looks the way it's supposed to. However, in the main loop of my program: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Menu_File_Exit Exit Case $Menu_Cat_Trays _SetActions(0) Case $Menu_Cat_Strains _SetActions(1) Case $Menu_Act_Add_Strain MsgBox(0,"","Got Menu_Act_Add_Strain") EndSwitch WEnd The "Case $Menu_Act_Add_Strain" fires on every iteration of the loop. What am I doing wrong here? I'm sure it's something simple, but I'm stuck. If there's a better way to do this, I'm all ears. Thanks in advance.