Exemple #1
0
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 );
}
Exemple #2
0
bool WRLoadResourceFrom_RC( WRInfo *info )
{
    WResTargetOS        target_os;
    WRFileType          target;
    char                fn_path[_MAX_PATH];
    bool                is_wres;
    bool                ok;

    ok = (info != NULL && info->file_name != NULL);

    if( ok ) {
        WRGetInternalRESName( info->file_name, fn_path );
    }

#ifndef __NT__
    if( ok ) {
        target = WRIdentifyFile( fn_path );
        ok = !WRIs32Bit( target );
        if( !ok ) {
            WRDisplayErrorMsg( WR_NOLOAD32IN16 );
        }
    }
#endif

    if( ok ) {
        ok = loadResDirFromRES( info, fn_path, &is_wres );
    }

    if( ok ) {
        target_os = WResGetTargetOS( info->dir );
        target = WR_INVALID_FILE;
        switch( target_os ) {
        case WRES_OS_WIN16:
            target = WR_WIN16M_RES;
            if( is_wres ) {
                target = WR_WIN16W_RES;
            }
            break;
        case WRES_OS_WIN32:
            target = WR_WINNTM_RES;
            if( is_wres ) {
                target = WR_WINNTW_RES;
            }
            break;
        }
        info->internal_type = target;
        if( target == WR_INVALID_FILE ) {
            WRDisplayErrorMsg( WR_INVALIDFILE );
            ok = false;
        }
    }

    if( ok ) {
        info->internal_filename = WRStrDup( fn_path );
        ok = (info->internal_filename != NULL);
    }

    return( ok );
}
Exemple #3
0
WMenuHandle WRESEAPI WRMenuStartEdit( WMenuInfo *info )
{
    int             ok;
    WMenuEditInfo   *einfo;

    einfo = NULL;

    ok = (info != NULL && info->parent != NULL && info->inst != NULL);

    if( ok ) {
        if( appWidth == -1 ) {
            WInitEditDlg( WGetEditInstance(), info->parent );
        }
        ok = ((einfo = WAllocMenuEInfo()) != NULL);
    }

    if( ok ) {
        einfo->info = info;
        einfo->menu = WMakeMenuFromInfo( info );
        ok = (einfo->menu != NULL);
    }

    if( ok ) {
        if( einfo->info->file_name != NULL ) {
            einfo->file_name = WStrDup( einfo->info->file_name );
            ok = (einfo->file_name != NULL);
            if( ok ) {
                einfo->file_type = WRIdentifyFile( einfo->file_name );
                ok = (einfo->file_type != WR_DONT_KNOW);
            }
        }
    }

    if( ok ) {
        ok = WResolveMenuEntries( einfo );
    }

    if( ok ) {
        ok = WCreateEditWindow( WGetEditInstance(), einfo );
    }

    if ( ok ) {
        einfo->hndl = WRegisterEditSession( einfo );
        ok = (einfo->hndl != 0);
    }

    if( !ok ) {
        if( einfo != NULL ) {
            WFreeMenuEInfo( einfo );
        }
        return( 0 );
    }

    return( einfo->hndl );
}
Exemple #4
0
WAccelHandle WRESEAPI WAccelStartEdit( WAccelInfo *info )
{
    bool            ok;
    WAccelEditInfo  *einfo;

    einfo = NULL;

    ok = (info != NULL && info->parent != NULL && info->inst != NULL);

    if( ok ) {
        if( appWidth == -1 ) {
            WInitEditDlg( WGetEditInstance(), info->parent );
        }
        ok = ((einfo = WAllocAccelEInfo()) != NULL);
    }

    if( ok ) {
        einfo->info = info;
        einfo->tbl = WMakeAccelTableFromInfo( info );
        ok = (einfo->tbl != NULL);
    }

    if( ok ) {
        if( einfo->info->file_name != NULL ) {
            einfo->file_name = WStrDup( einfo->info->file_name );
            ok = (einfo->file_name != NULL);
            if( ok ) {
                einfo->file_type = WRIdentifyFile( einfo->file_name );
                ok = (einfo->file_type != WR_DONT_KNOW);
            }
        }
    }

    if( ok ) {
        ok = WResolveAllEntrySymbols( einfo );
    }

    if( ok ) {
        ok = WCreateEditWindow( WGetEditInstance(), einfo );
    }

    if( ok ) {
        einfo->hndl = WRegisterEditSession( einfo );
        ok = (einfo->hndl != 0);
    }

    if( !ok ) {
        if( einfo != NULL ) {
            WFreeAccelEInfo( einfo );
        }
        return( 0 );
    }

    return( einfo->hndl );
}
Exemple #5
0
WREResInfo *WRELoadResource( const char *file_name )
{
    WRFileType  file_type;
    WREResInfo  *res_info;
    Bool        ok;

    WRESetWaitCursor( TRUE );

    ok = ((res_info = WREAllocResInfo()) != 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 ) {
        file_type = res_info->info->file_type;
        if( res_info->info->internal_type != WR_DONT_KNOW ) {
            file_type = res_info->info->internal_type;
        }
        res_info->is32bit = WRIs32Bit( file_type );
    }

    if( ok ) {
        res_info->symbol_table = WRInitHashTable();
        ok = (res_info->symbol_table != NULL);
    }

    if( !ok ) {
        if( res_info != NULL ) {
            WREFreeResInfo( res_info );
            res_info = NULL;
        }
    }

    WRESetWaitCursor( FALSE );

    return( res_info );
}
Exemple #6
0
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 );
        }
    }
}
Exemple #7
0
int PASCAL WinMain( HINSTANCE hinstCurrent, HINSTANCE hinstPrevious,
                    LPSTR lpszCmdLine, int nCmdShow )
{
    int                 ret;
    int                 i;
    int                 ltype;
    int                 stype;
    bool                backup;
    WRInfo              *info;
    WRFileType          ftype;
    uint_16             mflags;
    WRSelectImageInfo   *sii;
#if 0
    bool                dup;
    char                *data;
    WResID              type;
    WResID              name;
#endif

    hinstCurrent = hinstCurrent;
    hinstPrevious = hinstPrevious;
    lpszCmdLine = lpszCmdLine;
    nCmdShow = nCmdShow;

    info = NULL;
    ret = TRUE;

    WRInit();
    if( _argc == 6 ) {
        ltype = atoi( _argv[2] );
        stype = atoi( _argv[4] );
        backup = (atoi( _argv[5] ) != 0);
        if( stype != 0 ) {
            info = WRLoadResource( _argv[1], ltype );
            if( info != NULL ) {
                info->save_name = _argv[3];
                info->save_type = stype;
                ret = WRSaveResource( info, backup );
            } else {
                ret = FALSE;
            }
        }
#if 0
    } else if( _argc == 2 ) {
        ret = FALSE;
        data = WRMemAlloc( 32 );
        if( data != NULL ) {
            for( i = 0; i < 32; i++ ) {
                data[i] = i;
            }
            type.IsName = name.IsName = FALSE;
            type.ID.Num = 10;
            name.ID.Num = 200;
            ret = WRSaveObjectAs( _argv[1], WR_WIN16M_RES, &type, &name, data, 32, 0 );
            WRMemFree( data );
        }
    } else if( _argc == 3 ) {
        ret = FALSE;
        data = WRMemAlloc( 32 );
        if( data != NULL ) {
            for( i = 0; i < 32; i++ ) {
                data[i] = i;
            }
            type.IsName = name.IsName = FALSE;
            type.ID.Num = 10;
            name.ID.Num = 100;
            ret = WRSaveObjectInto( _argv[1], &type, &name, data, 32, 0, &dup );
            WRMemFree( data );
        }
#endif
    } else {
        for( i = 1; i < _argc; i++ ) {
            WRSelectFileType( HWND_DESKTOP, _argv[i], FALSE, i % 2, NULL );
            ftype = WRIdentifyFile( _argv[i] );
        }
        ret = TRUE;
    }

    WRChangeMemFlags( HWND_DESKTOP, "test", &mflags, NULL );

    if( info != NULL ) {
        info->save_name = NULL;
        WRFreeWRInfo( info );
    }

    info = WRLoadResource( _argv[1], WR_DONT_KNOW );
    sii = WRSelectImage( HWND_DESKTOP, info, NULL );
    if( sii != NULL ) {
        WRFreeSelectImageInfo( sii );
    }
    WRFreeWRInfo( info );

    if( !ret ) {
        MessageBox( (HWND)NULL, "Error occurred!", "TEST WR",
                    MB_ICONEXCLAMATION | MB_OK | MB_APPLMODAL );
    }

    WRFini();

    return( ret );
}