bool WRENewResource( WRECurrentResInfo *curr, WResID *tname, WResID *rname, uint_16 memflags, uint_32 offset, uint_32 length, WResLangType *lang, bool *dup, uint_16 type, bool new_type ) { bool ok; ok = (curr != NULL && curr->info != NULL && tname != NULL && rname != NULL && lang != NULL); if( ok && ( curr->info->info->dir == NULL ) ) { ok = ((curr->info->info->dir = WResInitDir()) != NULL); } if( ok ) { ok = !WResAddResource( tname, rname, memflags, offset, length, curr->info->info->dir, lang, dup ); } if( ok ) { ok = (dup == NULL || (dup != NULL && !*dup)); } if( ok ) { if( new_type ) { curr->info->current_type = 0; ok = WREInitResourceWindow( curr->info, type ); } else { WRESetResNamesFromType( curr->info, type, TRUE, rname, 0 ); } } if( ok && new_type ) { curr->type = WREFindTypeNodeFromWResID( curr->info->info->dir, tname ); ok = (curr->type != NULL); } if( ok ) { curr->res = WREFindResNodeFromWResID( curr->type, rname ); ok = (curr->res != NULL); } if( ok ) { curr->lang = WREFindLangNodeFromLangType( curr->res, lang ); ok = (curr->lang != NULL); } return( ok ); }
bool WRERemoveEmptyResource( WRECurrentResInfo *curr ) { char *name; int type; bool ok; LRESULT index; HWND res_lbox; name = NULL; ok = true; 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 ) { 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( name != NULL ) { WRMemFree( name ); } return( ok ); }
Bool WREInitResourceWindow( WREResInfo *info, uint_16 type ) { Bool ok; ok = (info != NULL && info->info != NULL); if( ok ) { ok = WREInitTypeListBox( info->info_win, info->info->dir ); } if( ok ) { ok = WRESetResNamesFromType( info, type, FALSE, NULL, 0 ); } return( ok ); }
bool WREGetAccelSessionData( WREAccelSession *session, bool close ) { bool ok; ok = (session != NULL && session->hndl != 0 && session->lnode != NULL); if( ok ) { if( close ) { session->info = WAccelEndEdit( session->hndl ); } else { session->info = WAccelGetEditInfo( session->hndl ); } ok = (session->info != NULL); } if( ok && session->info->modified ) { ok = WRERenameWResResNode( session->tnode, &session->rnode, session->info->res_name ); WRESetResNamesFromType( session->rinfo, RESOURCE2INT( RT_ACCELERATOR ), TRUE, session->info->res_name, 0 ); } if( ok && session->info->modified ) { if( session->lnode->data != NULL ) { WRMemFree( session->lnode->data ); } session->lnode->data = session->info->data; session->lnode->Info.lang = session->info->lang; session->lnode->Info.Length = session->info->data_size; session->lnode->Info.MemoryFlags = session->info->MemFlags; session->lnode->Info.Offset = 0; session->info->data = NULL; session->info->data_size = 0; session->info->modified = false; session->rinfo->modified = true; } 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 ); }
static void startEditors( void ) { WRFileType ftype; WREResInfo *res_info; Bool editor_started; Bool ret; int num_types; uint_16 type; if( WREGetNumRes() != 1 ) { if( WRENoInterface ) { WREDisplayErrorMsg( WRE_INVALIDINPUTFILE ); PostMessage( WREMainWin, WM_CLOSE, 0, 0 ); } return; } editor_started = FALSE; num_types = 0; res_info = WREGetCurrentRes(); ftype = res_info->info->file_type; if( res_info->info->file_name == NULL ) { ftype = WRIdentifyFile( res_info->info->save_name ); } else { num_types = res_info->info->dir->NumTypes; } if( ftype != WR_WIN_RC_STR && ftype != WR_WIN_RC_MENU && ftype != WR_WIN_RC_ACCEL ) { if( WRENoInterface ) { if( !editor_started ) { WREDisplayErrorMsg( WRE_INVALIDINPUTFILE ); PostMessage( WREMainWin, WM_CLOSE, 0, 0 ); } } return; } if( num_types == 1 || num_types == 2 ) { ret = FALSE; type = 0; if( ftype == WR_WIN_RC_STR ) { type = (uint_16)RT_STRING; } else if( ftype == WR_WIN_RC_MENU ) { type = (uint_16)RT_MENU; } else if( ftype == WR_WIN_RC_ACCEL ) { type = (uint_16)RT_ACCELERATOR; } if( type != 0 && WREFindTypeNode( res_info->info->dir, type, NULL ) ) { ret = WRESetResNamesFromType( res_info, type, FALSE, NULL, 0 ); if( ret ) { editor_started = WREHandleResEdit(); } } } else if( num_types == 0 ) { if( ftype == WR_WIN_RC_STR ) { editor_started = WRENewStringResource(); } else if( ftype == WR_WIN_RC_MENU ) { editor_started = WRENewMenuResource(); } else if( ftype == WR_WIN_RC_ACCEL ) { editor_started = WRENewAccelResource(); } } if( WRENoInterface ) { if( !editor_started ) { WREDisplayErrorMsg( WRE_INVALIDINPUTFILE ); PostMessage( WREMainWin, WM_CLOSE, 0, 0 ); } } }
Bool pleaseOpenFile( UINT msg ) { char *filter; char *title; char *name; WREResInfo *res_info; WREResInfo *old_info; WREGetFileStruct gf; uint_16 type; Bool ok; old_info = WREGetCurrentRes(); res_info = NULL; filter = NULL; title = NULL; name = NULL; if( msg == ACCEL_PLEASE_OPENME ) { filter = WREAccelFilter; title = WREAllocRCString( WRE_OPENACCEL ); type = (uint_16)RT_ACCELERATOR; } else if( msg == MENU_PLEASE_OPENME ) { filter = WREMenuFilter; title = WREAllocRCString( WRE_OPENMENU ); type = (uint_16)RT_MENU; } else if( msg == STRING_PLEASE_OPENME ) { filter = WREStringFilter; title = WREAllocRCString( WRE_OPENSTRING ); type = (uint_16)RT_STRING; } ok = (filter != NULL && title != NULL); if( ok ) { gf.file_name = NULL; gf.title = title; gf.filter = filter; gf.save_ext = FALSE; ok = ((name = WREGetOpenFileName( &gf )) != NULL); } if( ok ) { ok = ((res_info = WRELoadResource( name )) != NULL); } if( ok ) { WREFindAndLoadSymbols( res_info ); ok = WRECreateResourceWindow( res_info ); } if( ok ) { ListAddElt( &WREResList, (void *)res_info ); } if( ok ) { ok = (WREFindTypeNode( res_info->info->dir, type, NULL ) != NULL); } if( ok ) { ok = WRESetResNamesFromType( res_info, type, FALSE, NULL, 0 ); } if( ok ) { ok = WREHandleResEdit(); } if( ok ) { SendMessage( old_info->res_win, WM_CLOSE, 0, 0 ); } if( !ok ) { if( res_info != NULL ) { WREFreeResInfo( res_info ); res_info = NULL; } } if( name != NULL ) { WREMemFree( name ); } if( title != NULL ) { WREFreeRCString( title ); } return( ok ); }