WdeResInfo *WdeLoadResource( const char *file_name ) { WdeResInfo *res_info; WRFileType file_type; bool ok; WdeSetWaitCursor( TRUE ); ok = ((res_info = WdeAllocResInfo()) != NULL); if( ok ) { file_type = WRIdentifyFile( file_name ); ok = (file_type != WR_INVALID_FILE); } if( ok ) { res_info->info = WRLoadResource( file_name, file_type ); ok = (res_info->info != NULL); } if( ok ) { res_info->dlg_entry = WdeFindTypeNode( res_info->info->dir, RESOURCE2INT( RT_DIALOG ), "DIALOG" ); } if( !ok ) { if( res_info != NULL ) { WdeFreeResInfo( res_info ); res_info = NULL; } } WdeSetWaitCursor( FALSE ); return( res_info ); }
bool WdeSaveResourceToFile( WdeResInfo *res_info ) { bool ok; char fn[_MAX_PATH]; WdeSetWaitCursor( TRUE ); ok = (res_info != NULL && res_info->info != NULL); if( ok ) { if( res_info->info->save_type == WR_WIN_RC_DLG || res_info->info->save_type == WR_WIN_RC ) { if( res_info->info->internal_type == WR_DONT_KNOW ) { WRGetInternalRESName( res_info->info->save_name, fn ); res_info->info->internal_type = WdeSelectFileType( fn, res_info->is32bit ); } } } if( ok ) { ok = WdeInfoToData( res_info ); } if( ok ) { if( res_info->info->save_type == WR_WIN_RC_DLG || res_info->info->save_type == WR_WIN_RC ) { ok = WdeSaveRC( res_info->info->save_name, res_info ); } } // if we are saving a .RES file then auto create a dlg script if( ok ) { if( res_info->info->save_type == WR_WIN16M_RES || res_info->info->save_type == WR_WIN16W_RES || res_info->info->save_type == WR_WINNTM_RES || res_info->info->save_type == WR_WINNTW_RES ) { char dlgName[_MAX_PATH]; if( WdeCreateDLGName( res_info->info->save_name, dlgName ) ) { ok = WdeSaveRC( dlgName, res_info ); } } } if( ok ) { ok = WRSaveResource( res_info->info, true ); } if( ok ) { WdeSetResModified( res_info, FALSE ); } if( res_info != NULL && res_info->info->save_type != WR_WIN_RC_DLG ) { WdeFreeInfoData( res_info ); } WdeSetWaitCursor( FALSE ); return( ok ); }
bool WdeSaveObject( WdeResInfo *rinfo, WdeDialogBoxInfo *dbi, char **fname, WResID *rname, WResLangType *langtype, bool save_into, bool get_name ) { void *rdata; uint_32 size; bool ok; WResLangType lang; WdeSetWaitCursor( TRUE ); ok = (rinfo != NULL && dbi != NULL); if( ok ) { if( langtype != NULL ) { lang = *langtype; } else { lang.lang = DEF_LANG; lang.sublang = DEF_SUBLANG; } ok = WdeDBI2Mem( dbi, (unsigned_8 **)&rdata, &size ); } if( ok ) { if( save_into ) { ok = WdeSaveObjectInto( rinfo, dbi, rname, rdata, size, &lang ); } else { ok = WdeSaveObjectAs( rinfo, dbi, fname, rname, rdata, size, &lang, get_name ); } } if( rdata != NULL ) { WRMemFree( rdata ); } WdeSetWaitCursor( FALSE ); return( ok ); }
bool WdeOpenResource( char *fn ) { char *name; WdeResInfo *res_info; WdeGetFileStruct gf; bool ok, got_name; WdeSetWaitCursor( TRUE ); res_info = NULL; name = NULL; got_name = FALSE; if( fn != NULL ) { if( WdeFileExists( fn ) ) { name = WdeStrDup( fn ); gf.fn_offset = WRFindFnOffset( name ); } else { return( FALSE ); } } else { gf.file_name = NULL; gf.title = WdeResOpenTitle; gf.filter = WdeResOpenFilter; ok = ((name = WdeGetOpenFileName( &gf )) != NULL); } if( ok ) { got_name = TRUE; ok = ((res_info = WdeLoadResource( name )) != NULL); } if( ok ) { res_info->hash_table = WRInitHashTable(); ok = (res_info->hash_table != NULL); } if( ok ) { if( res_info->info->internal_type != WR_DONT_KNOW ) { res_info->is32bit = WRIs32Bit( res_info->info->internal_type ); } else { res_info->is32bit = WRIs32Bit( res_info->info->file_type ); } ok = WdeAddDlgItems( res_info ); } if( ok ) { WdeFindAndLoadSymbols( res_info ); ok = WdeCreateResourceWindow( res_info, gf.fn_offset, NULL ); } if( ok ) { if( WdeResInfoHasDialogs( res_info ) ) { WdeSelectDialog( res_info ); } else { WdeDisplayErrorMsg( WDE_PRJHASNODIALOGS ); } ListAddElt( &WdeResList, (void *)res_info ); WdeSetResModified( res_info, FALSE ); WdeCheckBaseScrollbars( FALSE ); } if( !ok ) { if( res_info != NULL ) { WdeFreeResInfo( res_info ); res_info = NULL; } if( got_name ) { WdeDisplayErrorMsg( WDE_RESOURCESNOTLOADED ); } } if( name != NULL ) { WRMemFree( name ); } WdeSetWaitCursor( FALSE ); return( ok ); }