Beispiel #1
0
char *WCreateEditTitle( WAccelEditInfo *einfo )
{
    char        *title;
    char        *fname;
    char        *text;
    int         offset;
    size_t      len;

    title = NULL;
    fname = NULL;

    if( einfo == NULL ) {
        return( NULL );
    }

    if( einfo->file_name == NULL ) {
        fname = einfo->info->file_name;
    } else {
        fname = einfo->file_name;
    }

    text = AllocRCString( W_ACCELAPPTITLE );

    if( fname == NULL || text == NULL ) {
        return( NULL );
    }

    offset = WRFindFnOffset( fname );
    fname = &fname[offset];
    len = strlen( fname ) + strlen( text ) + 6;
    title = (char *)WRMemAlloc( len );
    if( title != NULL ) {
        strcpy( title, text );
        strcat( title, " - [" );
        strcat( title, fname );
        strcat( title, "]" );
    }

    if( text != NULL ) {
        FreeRCString( text );
    }

    return( title );
}
Beispiel #2
0
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 );
}