bool WDeleteEditWinLBoxEntry( WMenuEditInfo *einfo, LRESULT pos, bool free_it ) { HWND lbox; bool ok; WMenuEntry *entry; LRESULT ret; LRESULT count; ok = ( einfo != NULL && einfo->edit_dlg != NULL ); if( ok ) { lbox = GetDlgItem( einfo->edit_dlg, IDM_MENUEDLIST ); ok = ( lbox != NULL ); } if( ok ) { count = SendMessage( lbox, LB_GETCOUNT, 0, 0 ); ok = ( count != 0 && count != LB_ERR && pos < count ); } if( ok ) { entry = (WMenuEntry *)SendMessage( lbox, LB_GETITEMDATA, (WPARAM)pos, 0 ); if( entry != NULL ) { if( free_it ) { ok = WRemoveMenuEntry( einfo->menu, entry ); if( ok ) { WFreeMenuEntries( entry->child ); WFreeMenuEntry( entry ); } } } else { ok = false; } } if( ok ) { einfo->info->modified = true; if( free_it ) { ret = WInitEditWindowListBox( einfo ); } else { ret = SendMessage( lbox, LB_DELETESTRING, (WPARAM)pos, 0 ); } ok = ( ret != LB_ERR ); } if( ok ) { einfo->current_entry = NULL; einfo->current_pos = LB_ERR; if( pos > count - 2 ) pos = count - 2; ok = ( SendMessage( lbox, LB_SETCURSEL, (WPARAM)pos, 0 ) != LB_ERR ); if( ok ) { WHandleSelChange( einfo ); } else { WSetEditWindowControls( einfo, NULL ); } } return( ok ); }
static Bool WShiftEntry( WMenuEditInfo *einfo, Bool left ) { WMenuEntry *prev; WMenuEntry *parent; WMenuEntry *entry; LRESULT ret; HWND lbox; Bool entry_removed; Bool ok; entry_removed = FALSE; ok = (einfo != NULL && einfo->edit_dlg != NULL); if( ok ) { lbox = GetDlgItem( einfo->edit_dlg, IDM_MENUEDLIST ); ok = (lbox != NULL); } if( ok ) { ret = SendMessage( lbox, LB_GETCURSEL, 0, 0 ); ok = (ret != LB_ERR); } if( ok ) { entry = (WMenuEntry *)SendMessage( lbox, LB_GETITEMDATA, (WPARAM)ret, 0 ); ok = (entry != NULL); } if( ok ) { parent = entry->parent; prev = entry->prev; ok = WRemoveMenuEntry( einfo->menu, entry ); if( ok ) { entry_removed = TRUE; } } if( ok ) { if( left ) { ok = WInsertEntryIntoMenu( einfo, parent, parent->parent, entry, FALSE ); } else { if( prev->child != NULL ) { parent = prev; for( prev = parent->child; prev != NULL && prev->next != NULL; prev = prev->next ); ok = WInsertEntryIntoMenu( einfo, prev, parent, entry, FALSE ); } else { ok = WInsertEntryIntoMenu( einfo, prev, parent, entry, TRUE ); } } } if( ok ) { ok = WInitEditWindowListBox( einfo ); } if( ok ) { einfo->info->modified = TRUE; einfo->current_entry = NULL; einfo->current_pos = -1; ret = SendMessage( lbox, LB_SETCURSEL, (WPARAM)ret, 0 ); ok = (ret != LB_ERR); if( ok ) { WHandleSelChange( einfo ); } } if( !ok ) { if( entry_removed ) { WFreeMenuEntries( entry->child ); WFreeMenuEntry( entry ); WInitEditWindowListBox( einfo ); } } return( ok ); }