/* * 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 */
static HMENU ChangeMenuToPopup ( gui_window *wnd, HMENU hmenu, gui_ctl_id id, hint_type type ) { HMENU popup; char name[MAX_STR]; unsigned menu_flags; unsigned attr_flags; popup = _wpi_createpopupmenu(); if( popup != (HMENU)NULL ) { _wpi_getmenutext( hmenu, id, name, MAX_STR - 1, FALSE ); GetMenuFlags( hmenu, id, false, &menu_flags, &attr_flags ); _wpi_modifymenu( hmenu, id, menu_flags | MF_POPUP, attr_flags, id, popup, name, FALSE ); GUIDrawMenuBar( wnd ); InsertPopup( wnd, id, popup, type ); } return( popup ); }