void GetStateForMenu( gui_window *wnd, gui_ctl_id id, WPI_MENUSTATE *mstate ) { HMENU hmenu, popup, parent; gui_ctl_idx position; hmenu = GUIGetHMENU( wnd ); if( hmenu == NULLHANDLE ) { return; } popup = GetPopupHMENU( wnd, hmenu, id, &parent, &position, MENU_HINT ); if( popup != NULLHANDLE ) { _wpi_getmenustate( parent, position, mstate, TRUE ); } else { _wpi_getmenustate( hmenu, id, mstate, FALSE ); } }
static bool GetMenuFlags( HMENU hmenu, gui_ctl_id id_position, bool by_position, unsigned *menu_flags, unsigned *attr_flags ) { WPI_MENUSTATE mstate; if( hmenu != NULLHANDLE ) { _wpi_getmenustate( hmenu, id_position, &mstate, ( by_position ) ? TRUE : FALSE ); _wpi_getmenuflagsfromstate( &mstate, menu_flags, attr_flags ); return( true ); } return( false ); }
/* * duplicateMenu - create a duplicate copy of a menu */ static HMENU duplicateMenu( HMENU orig ) { WPI_MENUSTATE mstate; int num; unsigned menu_flags; unsigned attr_flags; UINT id; char name[MAX_STR]; int i; HMENU copy; HMENU sub; if( orig != NULLHANDLE ) { copy = _wpi_createpopupmenu(); if( copy == NULLHANDLE ) { return( NULLHANDLE ); } num = (int)_wpi_getmenuitemcount( orig ); for( i = 0; i < num; i++ ) { if( _wpi_getmenustate( orig, i, &mstate, TRUE ) ) { _wpi_getmenuflagsfromstate( &mstate, &menu_flags, &attr_flags ); if( _wpi_ismenuseparatorfromstate( &mstate ) ) { _wpi_appendmenu( copy, menu_flags, attr_flags, 0, NULLHANDLE, NULL ); } else if( _wpi_ismenupopupfromstate( &mstate ) ) { sub = duplicateMenu( _wpi_getsubmenu( orig, i ) ); name[0] = 0; _wpi_getmenutext( orig, i, name, MAX_STR - 1, TRUE ); _wpi_appendmenu( copy, menu_flags, attr_flags, 0, sub, name ); } else { id = _wpi_getmenuitemid( orig, i ); _wpi_getmenutext( orig, i, name, MAX_STR - 1, TRUE ); _wpi_appendmenu( copy, menu_flags, attr_flags, id, NULLHANDLE, name ); } } } } return( copy ); } /* duplicateMenu */
bool GUIInsertMenuByID( gui_window *wnd, gui_ctl_id id, gui_menu_struct *menu ) { WPI_MENUSTATE mstate; HMENU hmenu; gui_ctl_idx position; HMENU parent; bool made_root; bool ret; ret = false; hmenu = GetOrMakeHMENU( wnd, false, &made_root ); if( !_wpi_getmenustate( hmenu, id, &mstate, FALSE ) ) { if( GetPopupHMENU( wnd, hmenu, id, &parent, &position, MENU_HINT ) != NULLHANDLE ) { ret = AddMenu( parent, wnd, menu, true, position, true, MENU_HINT ); } } else { ret = AddMenu( hmenu, wnd, menu, true, id, false, MENU_HINT ); } if( ret && made_root ) { GUISetMenu( wnd, hmenu ); } return( ret ); }