Bool WREAddResNames( WREResInfo *info ) { HWND resLbox; HWND typeLbox; WResTypeNode *tnode; Bool redrawOff; LRESULT index; Bool ok; redrawOff = FALSE; ok = (info != NULL); if( ok ) { typeLbox = GetDlgItem( info->info_win, IDM_RNTYPE ); resLbox = GetDlgItem( info->info_win, IDM_RNRES ); ok = (typeLbox != (HWND)NULL && resLbox != (HWND)NULL); } if( ok ) { SendMessage( resLbox, WM_SETREDRAW, FALSE, 0 ); redrawOff = TRUE; WREResetListbox( resLbox ); index = SendMessage( typeLbox, LB_GETCURSEL, 0, 0 ); ok = (index != LB_ERR); } if( ok ) { tnode = (WResTypeNode *)SendMessage( typeLbox, LB_GETITEMDATA, (WPARAM)index, 0 ); ok = (tnode != NULL); } if( ok ) { info->current_type = tnode->Info.TypeName.ID.Num; ok = WRESetResNamesFromTypeNode( resLbox, tnode ); } if( redrawOff ) { SendMessage( resLbox, WM_SETREDRAW, TRUE, 0 ); InvalidateRect( resLbox, NULL, TRUE ); WRESetTotalText( info ); } return( ok ); }
bool WREDeleteResource( WRECurrentResInfo *curr, bool force ) { char *name; int type; bool ok; LRESULT index; HWND res_lbox; WResLangNode *lnode; name = NULL; lnode = NULL; if( curr->info->current_type == RESOURCE2INT( RT_STRING ) ) { return( WREDeleteStringResources( curr, FALSE ) ); } ok = (curr->info != NULL && curr->res != NULL && curr->lang != NULL); if( ok ) { if( curr->type->Info.TypeName.IsName ) { type = 0; } else { type = curr->type->Info.TypeName.ID.Num; } name = WREGetResName( curr->res, type ); ok = (name != NULL); } if( ok && !force ) { ok = WREQueryDeleteName( name ); } // nuke any edit sessions on this resource if( ok ) { lnode = curr->lang; switch( type ) { case RT_MENU: WREEndLangMenuSession( lnode ); break; case RT_STRING: WREEndResStringSessions( curr->info ); break; case RT_ACCELERATOR: WREEndLangAccelSession( lnode ); break; case RT_DIALOG: WREEndLangDialogSession( lnode ); break; case RT_GROUP_CURSOR: case RT_GROUP_ICON: ok = WREDeleteGroupImages( curr, (uint_16)type ); /* fall through */ case RT_BITMAP: if( ok ) { WREEndLangImageSession( lnode ); } break; } } if( ok ) { ok = WRRemoveLangNodeFromDir( curr->info->info->dir, &curr->type, &curr->res, &curr->lang ); curr->info->modified = true; } if( ok ) { if( !curr->type ) { curr->info->current_type = 0; ok = WREInitResourceWindow( curr->info, 0 ); } else { res_lbox = GetDlgItem( curr->info->info_win, IDM_RNRES ); index = SendMessage( res_lbox, LB_FINDSTRING, 0, (LPARAM)name ); if( index == LB_ERR ) { index = 0; } ok = WRESetResNamesFromType( curr->info, curr->info->current_type, TRUE, NULL, index ); } } if( ok ) { WRESetTotalText( curr->info ); } if( name != NULL ) { WRMemFree( name ); } return( ok ); }
Bool WRESetResNamesFromType( WREResInfo *info, uint_16 type, Bool force, WResID *name, int index ) { HWND resLbox; HWND typeLbox; int typeIndex; WResTypeNode *tnode; LRESULT max_index; char *str; Bool ok; tnode = NULL; ok = (info != NULL); if( ok && type != 0 && info->current_type == type && !force ) { return( TRUE ); } if( ok ) { resLbox = GetDlgItem( info->info_win, IDM_RNRES ); typeLbox = GetDlgItem( info->info_win, IDM_RNTYPE ); ok = (resLbox != (HWND)NULL && typeLbox != (HWND)NULL); } if( ok ) { WREResetListbox( resLbox ); typeIndex = 0; if( type != 0 ) { typeIndex = WREFindTypeLBoxIndex( typeLbox, type, &tnode ); } else { LRESULT count; count = SendMessage( typeLbox, LB_GETCOUNT, 0, 0 ); if( count != 0 && count != LB_ERR ) { tnode = (WResTypeNode *)SendMessage( typeLbox, LB_GETITEMDATA, (WPARAM)typeIndex, 0 ); } } if( typeIndex == -1 ) { return( TRUE ); } info->current_type = type; SendMessage( typeLbox, LB_SETCURSEL, (WPARAM)typeIndex, 0 ); } if( ok ) { if( tnode != NULL ) { info->current_type = tnode->Info.TypeName.ID.Num; ok = WRESetResNamesFromTypeNode( resLbox, tnode ); } else { info->current_type = 0; } } if( ok ) { if( name != NULL ) { index = LB_ERR; str = WResIDToStr( name ); if( str != NULL ) { index = (int)SendMessage( resLbox, LB_FINDSTRING, 0, (LPARAM)str ); WREMemFree( str ); } if( index == LB_ERR ) { index = 0; } } max_index = SendMessage( resLbox, LB_GETCOUNT, 0, 0 ); if( max_index == LB_ERR ) { max_index = 0; } index = min( index, max_index - 1 ); SendMessage( resLbox, LB_SETCURSEL, (WPARAM)index, 0 ); WRESetTotalText( info ); if( GetActiveWindow() == WREGetMainWindowHandle() ) { SetFocus( resLbox ); } } return( ok ); }