Menu

The Menu structure contains functions and structures to create and operate on menus.

structure Menu:
  sig
    type HMENU and HBITMAP and HWND and HINSTANCE
    type RECT =  { left: int, top: int, right: int, bottom: int }
	
    datatype MenuFlag =
        MF_BYCOMMAND | MF_BYPOSITION | MF_SEPARATOR | MF_ENABLED | MF_GRAYED |
        MF_DISABLED | MF_UNCHECKED | MF_CHECKED | MF_USECHECKBITMAPS | MF_STRING |
        MF_BITMAP | MF_OWNERDRAW | MF_POPUP | MF_MENUBARBREAK | MF_MENUBREAK |
        MF_UNHILITE | MF_HILITE | MF_DEFAULT | MF_SYSMENU | MF_HELP |
        MF_RIGHTJUSTIFY | MF_MOUSESELECT

    datatype MenuIdOrHandle = MenuHandle of HMENU | MenuId of int

    datatype MenuItemOptions =
          MFT_MENUBARBREAK
        | MFT_MENUBREAK
        | MFT_RADIOCHECK
        | MFT_RIGHTJUSTIFY
        | MFT_RIGHTORDER

    datatype MenuItemType =
          MFT_BITMAP of HBITMAP
        | MFT_OWNERDRAW of int
        | MFT_SEPARATOR
        | MFT_STRING of string

    datatype MenuState =
          MFS_CHECKED
        | MFS_DEFAULT
        | MFS_DISABLED
        | MFS_ENABLED
        | MFS_GRAYED
        | MFS_HILITE
        | MFS_UNCHECKED
        | MFS_UNHILITE

    type MenuItemInfo =
        {
            menuType: MenuItemType,
            menuOptions: MenuItemOptions list,
            state: MenuState list,
            wID: int,
            hSubMenu: HMENU option,
            hbmpChecked: HBITMAP option,
            hbmpUnchecked: HBITMAP option,
            itemData: int
        }

    val AppendMenu : HMENU * MenuFlag list * MenuIdOrHandle * MenuItemType -> unit
    val CheckMenuRadioItem : HMENU * int * int * int * MenuFlag -> unit
    val CreateMenu : unit -> HMENU
    val CreatePopupMenu : unit -> HMENU
    val DeleteMenu : HMENU * int * MenuFlag -> unit
    val DestroyMenu : HMENU -> unit
    val DrawMenuBar : HWND -> unit
    val EnableMenuItem : HMENU * int * MenuFlag -> MenuFlag list
    val GetMenu : HWND -> HMENU

    datatype GMDIFlags = GMDI_GOINTOPOPUPS | GMDI_USEDISABLED
    val GetMenuDefaultItem : HMENU * bool * GMDIFlags list -> int

    val GetMenuItemCount : HMENU -> int
    val GetMenuItemID : HMENU -> int
    val GetMenuItemInfo : HMENU * int * bool -> MenuItemInfo
    val GetMenuItemRect : HWND * HMENU * int -> RECT
    val GetMenuState : HMENU * int * MenuFlag -> MenuFlag list * int
    val GetMenuString : HMENU * int * MenuFlag -> string
    val GetSubMenu : HMENU * int -> HMENU
    val GetSystemMenu : HWND * bool -> HMENU
    val HiliteMenuItem : HWND * HMENU * int * MenuFlag list -> unit
    val InsertMenu : HMENU * int * MenuFlag list * MenuIdOrHandle * MenuItemType -> unit
    val IsMenu : HMENU -> bool
    val LoadMenu : HINSTANCE * Resource.RESID -> HMENU
    val ModifyMenu : HMENU * int * MenuFlag list * MenuIdOrHandle * MenuItemType -> unit
    val RemoveMenu : HMENU * int * MenuFlag -> unit
    val SetMenu : HWND * HMENU option -> unit
    val SetMenuItemInfo : HMENU * int * bool * MenuItemInfo -> unit
    val InsertMenuItem : HMENU * int * bool * MenuItemInfo -> unit

    datatype TrackPopupMenuOptions =
        TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_LEFTALIGN | TPM_CENTERALIGN | TPM_RIGHTALIGN |
        TPM_TOPALIGN | TPM_VCENTERALIGN | TPM_BOTTOMALIGN | (*TPM_HORIZONTAL | TPM_VERTICAL |*)
        TPM_NONOTIFY | TPM_RETURNCMD
    val TrackPopupMenu : HMENU * TrackPopupMenuOptions list * int * int * HWND -> int

    val SetMenuContextHelpId: HMENU * int -> unit
    val GetMenuContextHelpId: HMENU -> int
  end