Documentation for Win32lib v0.70.18
Table of Contents

Menus

Routines that deal with menu and menuitem handling.


  • func attachMenuHandle(atom hMenu, integer newparent,object index,sequence caption)    Changes (or sets) the parent of the control id to newparent, using the index attachment data if it is relevant.
  • func attachPopup(integer pId, object pMenus)   Associates one or more menus to a control as popup or context menus.
  • proc defineMenuRadioGroup( sequence ids)   Defines a set of menu items that form a radio-group
  • desc Get the count of items in /i menu ( /Menu or /Popup )   
  • func getCount( menu )   
  • func getMenuBar(integer window,integer returnHandle)   
  • func getMenuPosn(integer id)   Get the zero-based relative position of a menu item.
  • func inMenuBar(integer id)   Determines whether a menu belongs to a window menu bar.
  • func removeMenu(integer id,integer item,integer flag,integer reuse)   Removes a menu item from a menu.
  • func setMenuItemBitmaps(integer id,object bitmap)    Sets the bitmap on a menu item, or the checked/unchecked marks
  • func skipF10(integer NewValue)   Possibly sets whether or not F10 sets focus on the menubar

    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    attachMenuHandle
    (atom hMenu, integer newparent,object index,sequence caption)

    Changes (or sets) the parent of the control id to newparent, using the index attachment data if it is relevant.

    Returns: INTEGER: True if successful otherwise False.

    Category: Menus

    This function works like setParent(), but targets menus whose only the handle is known. They may have been created from a memory template. Since such a menu has no caption, you must supply one.

    See Also: attachPopup, defineMenuRadioGroup, Get the count of items in /i menu , getCount, getMenuBar, getMenuPosn, inMenuBar, removeMenu, setMenuItemBitmaps, skipF10


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    attachPopup
    (integer pId, object pMenus)

    Associates one or more menus to a control as popup or context menus.

    Returns: SEQUENCE: Previously attached menus.

    Category: Menus

    This will cause the menu(s) supplied in pMenu to be linked to the control pId such that when the righthand mouse button is pressed, the menu will pop up next to the mouse pointer.
    You can have different menus popup depending on the combination of Ctrl and Shift keys you have pressed. You do this by supplying up to four menu ids in pMenu, one for no keys pressed, one for shift key, one for control key, and another for both shift and control keys pressed.

    Each value in pMenu is either a Menu id, 0, -1, or a sequence of the form {MenuId, XOffset, YOffset}.
    If a simple menu id, then this is the popup menu that will display when the user right-clicks in the control.
    If -1, then the corresponding current value is retained. Use this to skip over setting previous values of menu ids.
    If 0, then the corresponding menu id is cleared and the popup will not display.
    If a sequence, then the XOffset and YOffset are used to position the menu relative to the mouse pointer. The default values are -6 and -6 respectively. Use this when you need the menu to be shown is different position.

    First you need to define the menus and any handlers for them, then you can attach them to one or more controls.

    Example

          -- Define two menus.
          MenuOne = create(Menu, "One", MainWindow, 0, 0, 0,0, 0)
            M1_Item1 = create(MenuItem, "Item 1.1", MenuOne, 0, 0, 0,0, 0)
            M1_Item2 = create(MenuItem, "Item 1.2", MenuOne, 0, 0, 0,0, 0)
            M1_Item3 = create(MenuItem, "Item 1.3", MenuOne, 0, 0, 0,0, 0)
          MenuTwo = create(Menu, "Two", MainWindow, 0, 0, 0,0, 0)
            M2_Item1 = create(MenuItem, "Item 2.1", MenuTwo, 0, 0, 0,0, 0)
            M2_Item2 = create(MenuItem, "Item 2.2", MenuTwo, 0, 0, 0,0, 0)
            M2_Item3 = create(MenuItem, "Item 2.3", MenuTwo, 0, 0, 0,0, 0)
          setHandler(M1_Item1, w32HClick, routine_id("Click_Item11"))
          setHandler(M1_Item2, w32HClick, routine_id("Click_Item12"))
          setHandler(M1_Item3, w32HClick, routine_id("Click_Item13"))
          setHandler(M2_Item1, w32HClick, routine_id("Click_Item21"))
          setHandler(M2_Item2, w32HClick, routine_id("Click_Item22"))
          setHandler(M2_Item3, w32HClick, routine_id("Click_Item23"))
    

    -- Now attach popups for normal and ctrl keys prevMenus = attachPopup(SomeFld, {MenuOne, -- Normal (no keys) -1, -- ignore Shift -- Note the changed X-Y offsets. {MenuTwo,-20,-10} -- Ctrl key })

    See Also: attachMenuHandle, defineMenuRadioGroup, Get the count of items in /i menu , getCount, getMenuBar, getMenuPosn, inMenuBar, removeMenu, setMenuItemBitmaps, skipF10


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    defineMenuRadioGroup
    ( sequence ids)

    Defines a set of menu items that form a radio-group

    Category: Menus

    ids is a list of menuitems that form a logical group of items, in which only one can be marked witha 'radio-button' icon.
    This routine ensures that only one item from the group will be marked. Any that were previously marked will be 'turned off'

    Note 1. The items do not have to be in the same menu.
    Note 2. A given menu item can only be in one radio group.

    Example:

          -- set the current loudness level.
           defineMenuRadioGroup({miPianissimo, miPiano, piModerato,
                                 miForte, miFortissimo})
          . . .
           setCheck( miForte, w32True)
          -- now, all items of the same group are unchecked, except for miForte
    

    See Also: attachMenuHandle, attachPopup, Get the count of items in /i menu , getCount, getMenuBar, getMenuPosn, inMenuBar, removeMenu, setMenuItemBitmaps, skipF10


    Documentation for Win32lib v0.70.18
    Table of Contents

    [desc]
    Get the count of items in /i menu
    ( /Menu or /Popup )

    Returns: Count of items, or zero if control's list is empty.

    Category: Menus

    This returns zero if menu is not an appropriate control type.

    Example:

              -- count size of TheList
              integer count
    

    count = getCount( TheMenu )

    See Also: attachMenuHandle, attachPopup, defineMenuRadioGroup, getCount, getMenuBar, getMenuPosn, inMenuBar, removeMenu, setMenuItemBitmaps, skipF10


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    getCount
    ( menu )

    Category: Menus

    See Also: attachMenuHandle, attachPopup, defineMenuRadioGroup, Get the count of items in /i menu , getMenuBar, getMenuPosn, inMenuBar, removeMenu, setMenuItemBitmaps, skipF10


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    getMenuBar
    (integer window,integer returnHandle)

    Returns: (ATOM) id of window menu bar if returnHandle is 0, else its Windows handle.

    Category: Menus

    See Also: attachMenuHandle, attachPopup, defineMenuRadioGroup, Get the count of items in /i menu , getCount, getMenuPosn, inMenuBar, removeMenu, setMenuItemBitmaps, skipF10


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    getMenuPosn
    (integer id)

    Get the zero-based relative position of a menu item.

    Returns: INTEGER: Zero-Based Position of the menu item, or -1 if not a menu item.

    Category: Menus

    id is the id of a menu (item).

    Example

      integer pos
      pos = getMenuPosn(miSave)
    

    See Also: attachMenuHandle, attachPopup, defineMenuRadioGroup, Get the count of items in /i menu , getCount, getMenuBar, inMenuBar, removeMenu, setMenuItemBitmaps, skipF10


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    inMenuBar
    (integer id)

    Determines whether a menu belongs to a window menu bar.

    Returns: (INTEGER) -1 if not a menu, 1 if the menu appears in a menu bar, else 0.

    Category: Menus

    See Also: attachMenuHandle, attachPopup, defineMenuRadioGroup, Get the count of items in /i menu , getCount, getMenuBar, getMenuPosn, removeMenu, setMenuItemBitmaps, skipF10


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    removeMenu
    (integer id,integer item,integer flag,integer reuse)

    Removes a menu item from a menu.

    Returns: (INTEGER) w32False on failure, else nonzero.

    Category: Menus

    item is a 0-based index if flag is w32False, else an item id which must belong to the menu id (or the menu bar of the window id). If reuse is w33False, Windows is asked to free the memory of the menu, effectively destroying item. By passing another value, and if item is a menu, the function will leave the internal data alone and return the handle.

    See Also: attachMenuHandle, attachPopup, defineMenuRadioGroup, Get the count of items in /i menu , getCount, getMenuBar, getMenuPosn, inMenuBar, setMenuItemBitmaps, skipF10


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    setMenuItemBitmaps
    (integer id,object bitmap)

    Sets the bitmap on a menu item, or the checked/unchecked marks

    Returns: SEQUENCE: the handles for unchecked,checked and main bitmaps

    Category: Menus

    id is the identifier of the menu item to be considered. If bitmap is an atom, it is the handle to the bitmap displayed by the item. If it is a sequence starting with a pair, the pair is {unchecked mark handle,checked mark handle}, and these marks will be set. If it is an empty sequence, no attempt to change anything will be made. Otherwise, bitmap is some text to be displayed instead of the current bitmap, if any. The returned value always has 3 elements, unless the function fails in any way, in which case it returns {}.

    See Also: attachMenuHandle, attachPopup, defineMenuRadioGroup, Get the count of items in /i menu , getCount, getMenuBar, getMenuPosn, inMenuBar, removeMenu, skipF10


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    skipF10
    (integer NewValue)

    Possibly sets whether or not F10 sets focus on the menubar

    Returns: Returns INTEGER: The current value of the flag.

    Category: Menus

    By default, the F10 key sets focus on the menubar. If NewValue is w32True, then the behaviour is changed so that the F10 key does not set focus on the menubar. Passing w32GetValue will just return the current value of the flag.

    Example:

          integer PrevF10Flag
          PrevF10Flag = skipF10( w32True )
    

    See Also: attachMenuHandle, attachPopup, defineMenuRadioGroup, Get the count of items in /i menu , getCount, getMenuBar, getMenuPosn, inMenuBar, removeMenu, setMenuItemBitmaps