/* GUIBEGIN WINDOW , 53, 175, 363, 138, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX|THICK, , Menu item add/remove demo FONT 8, 400, MS Shell Dlg MENU GROUP 6, 6, 222, 47, , , , , GuiAddMenu() PUSH 14, 19, 43, 25, MULTI|TABSTOP, , Add1, , Add Heading 3 PUSH 66, 19, 43, 25, MULTI|TABSTOP, , Add2, , Add Heading before 2 PUSH 116, 19, 43, 25, MULTI|TABSTOP, , AddItem1_3, , Item at 1 3 PUSH 167, 19, 43, 25, MULTI|TABSTOP, , Heading1_5, , Heading at 1 5 GROUP 6, 60, 221, 47, , , Del1, , GuiRemoveMenu() PUSH 14, 75, 43, 25, MULTI|TABSTOP, , Del1, , Heading at 1 5 PUSH 66, 75, 43, 25, MULTI|TABSTOP, , Del2, , Item "MySub2" PUSH 116, 75, 43, 25, MULTI|TABSTOP, , Del3, , Heading at 2 DEND MENU HEADING &Heading 1 ITEM Item &1 HEADING Item &2 ITEM Sub 1 ITEM Sub 2, MySub2 < ITEM ITEM Item &4 ITEM Item &5 < HEADING H&eading 2 ITEM Item &1 ITEM Item &2 < DEND GUIEND */ OPTIONS "C_CALL LABELCHECK NOSOURCE" /* This script demonstrates adding new headings and items to a menu on-the-fly. * We call GuiAddMenu() to do this, specifying a "HEADING" or "ITEM" option * (depending upon whether we're adding a heading or a selectable menu item). * When adding a menu item, we must know the "position" at which it falls. */ LIBRARY rexxgui GuiErr = "SYNTAX" GuiHeading = 1 GuiCreateWindow('NORMAL') Again: DO FOREVER GuiGetMsg() CATCH SYNTAX CONDITION('M') SIGNAL Again CATCH HALT FINALLY GuiDestroyWindow() END RETURN WM_CLICK_Add1: /* Add a heading at a position of 3. Note that if there's * a problem, SYNTAX will be raised since we set GuiErr for that. */ GuiAddMenu("Heading 3", "HEADING", 30) /* Disable the button so he can't click it again. */ GuiSetCtlPlacement("Add1", , , , , "DISABLE") RETURN WM_CLICK_Add2: /* Add a heading at a position of 2. Note that since there * is already a heading at position 2 (ie, "Heading 2"), * this will be inserted before that heading (and "Heading 2" * will consequently be pushed to a position of 3). */ GuiAddMenu("Before 2", "HEADING", 2) /* Disable the button so he can't click it again. */ GuiSetCtlPlacement("Add2", , , , , "DISABLE") RETURN WM_CLICK_AddItem1_3: /* Add an item at a position of 1 3. This means it will * fall under the heading at a position of 1 (ie, "Heading 1"). * It will be placed at a position of 3. Since we already have * an item at position 3 (ie, the separator line), this will be * inserted before that separator line (and the remaining items * under "Heading 1" will have their positions incremented. * * Note: The item has a caption of "Inserted 1", and has the * MARK option. */ GuiAddMenu("Inserted 1, , , MARK", "ITEM", "1 3") /* Disable the button so he can't click it again. */ GuiSetCtlPlacement("AddItem1_3", , , , , "DISABLE") RETURN WM_CLICK_Heading1_5: /* Add an heading at a position of 1 5. This means it will * fall under the heading at a position of 1 (ie, "Heading 1"). * It will be placed at a position of 5. * * Note: The item has a caption of "Heading insert". */ GuiAddMenu("Heading insert", "HEADING", "1 5") /* Add an item at a position of 1 5 1. This means it will * fall under the heading we just added above. */ GuiAddMenu("Inserted sub", "ITEM", "1 5 1") /* Disable the button so he can't click it again. */ GuiSetCtlPlacement("Heading1_5", , , , , "DISABLE") RETURN WM_CLICK_Del1: /* Delete the 5th item under the first heading. Note: * If the item doesn't exist, GuiRemoveMenu() does not * consider this an error. So it will not raise SYNTAX * in this case. */ GuiRemoveMenu("1 5") /* Disable the button so he can't click it again. */ GuiSetCtlPlacement("Del1", , , , , "DISABLE") RETURN WM_CLICK_Del2: /* Delete the menu item associated with the variable * "MySub2". It can be any position. Therefore, this * a very easy way of deleting an item. */ GuiRemoveMenu("MySub2", "VAR") /* Disable the button so he can't click it again. */ GuiSetCtlPlacement("Del2", , , , , "DISABLE") RETURN WM_CLICK_Del3: /* Delete menu heading 2 (and all items/sub-items under it. */ GuiRemoveMenu("2") /* Disable the button so he can't click it again. */ GuiSetCtlPlacement("Del3", , , , , "DISABLE") RETURN