Esempio n. 1
0
bool WREQueryPasteReplace( WResID *name, uint_16 type, bool *replace )
{
    WREPasteData        pdata;
    HWND                dialog_owner;
    DLGPROC             proc_inst;
    HINSTANCE           inst;
    INT_PTR             ret;

    if( name == NULL || type == 0 || replace == NULL ) {
        return( FALSE );
    }

    pdata.ret = 0;
    pdata.type = type;
    pdata.name = name;
    *replace = FALSE;
    dialog_owner  = WREGetMainWindowHandle();
    inst = WREGetAppInstance();
    proc_inst = (DLGPROC)MakeProcInstance( (FARPROC)WREResPasteProc, inst );

    ret = JDialogBoxParam( inst, "WREPaste", dialog_owner, proc_inst, (LPARAM)&pdata );

    FreeProcInstance( (FARPROC)proc_inst );

    if( ret == -1 || ret == IDCANCEL ) {
        return( FALSE );
    }

    if( ret == IDM_PASTE_REPLACE ) {
        *replace = TRUE;
    }

    return( TRUE );
}
Esempio n. 2
0
bool WREEditResourceSymbols( WREResInfo *info )
{
    WRHashEntryFlags    flags;
    FARPROC             cb;
    bool                ok;

    cb = NULL;
    ok = (info != NULL && info->symbol_table != NULL);

    if( ok ) {
        cb = MakeProcInstance( (FARPROC)WREHelpRoutine, WREGetAppInstance() );
        ok = (cb != (FARPROC)NULL);
    }

    if( ok ) {
        flags = WR_HASHENTRY_ALL;
        ok = WREditSym( info->info_win, &info->symbol_table, &flags, cb );
    }

    // ***** call routine to update the edit sessions *****

    if( cb != (FARPROC)NULL ) {
        FreeProcInstance( (FARPROC)cb );
    }

    return( ok );
}
Esempio n. 3
0
bool WREClipResource( WRECurrentResInfo *curr, HWND main, UINT fmt )
{
    WREClipData *cdata;
    HGLOBAL     hmem;
    BYTE        *mem;
    bool        ok;
    HINSTANCE   inst;

    cdata = NULL;
    mem = NULL;
    hmem = (HGLOBAL)NULL;
    ok = (curr != NULL && fmt != 0);

    if( ok ) {
        cdata = WRECreateClipData( curr );
        ok = (cdata != NULL);
    }

    if( ok ) {
        hmem = GlobalAlloc( GMEM_MOVEABLE, cdata->clip_size );
        ok = (hmem != (HGLOBAL)NULL);
    }

    if( ok ) {
        mem = GlobalLock( hmem );
        ok = (mem != NULL);
    }

    if( ok ) {
        memcpy( mem, cdata, cdata->clip_size );
        GlobalUnlock( hmem );
        mem = NULL;
        ok = OpenClipboard( main ) != 0;
    }

    if( ok ) {
        EmptyClipboard();
        SetClipboardData( fmt, hmem );
        SetClipboardData( CF_DSPBITMAP, WPrivateFormat );
        inst = WREGetAppInstance();
        WPrivateFormat = LoadBitmap( inst, "PrivateFmt" );
        CloseClipboard();
        hmem = (HGLOBAL)NULL;
        ok = (WPrivateFormat != (HBITMAP)NULL);
    }

    if( hmem != (HGLOBAL)NULL ) {
        GlobalFree( hmem );
    }

    if( cdata != NULL ) {
        WRMemFree( cdata );
    }

    return( ok );
}
Esempio n. 4
0
Bool WREChangeMemFlags( void )
{
    WRECurrentResInfo   curr;
    HWND                parent;
    char                *name;
    int                 type;
    uint_16             mflags;
    FARPROC             cb;
    Bool                ok;

    cb = NULL;
    name = NULL;
    mflags = 0;

    ok = WREGetCurrentResource( &curr );

    if( ok )  {
        if( curr.type->Info.TypeName.IsName ) {
            type = 0;
        } else {
            type = curr.type->Info.TypeName.ID.Num;
        }
        name   = WREGetResName( curr.res, type );
        parent = WREGetMainWindowHandle();
    }

    if( ok ) {
        cb = MakeProcInstance( (FARPROC)WREHelpRoutine, WREGetAppInstance() );
        ok = (cb != (FARPROC)NULL);
    }

    if( ok ) {
        mflags = curr.lang->Info.MemoryFlags;
        ok = WRChangeMemFlags( parent, name, &mflags, cb );
    }

    if( ok ) {
        curr.lang->Info.MemoryFlags = mflags;
    }

    if( cb != (FARPROC)NULL ) {
        FreeProcInstance( (FARPROC)cb );
    }

    if( name != NULL ) {
        WREMemFree( name );
    }

    return( ok );
}
Esempio n. 5
0
WREAccelSession *WREStartAccelSession( WRECurrentResInfo *curr )
{
    WREAccelSession *session;

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

    session = WREAllocAccelSession();
    if( session == NULL ) {
        return( NULL );
    }

    session->info = WAccAllocAccelInfo();
    if( session->info == NULL ) {
        return( NULL );
    }

    session->info->parent = WREGetMainWindowHandle();
    session->info->inst = WREGetAppInstance();
    session->info->file_name = WREStrDup( WREGetQueryName( curr->info ) );
    session->info->res_name = WRECopyWResID( &curr->res->Info.ResName );
    session->info->lang = curr->lang->Info.lang;
    session->info->MemFlags = curr->lang->Info.MemoryFlags;
    session->info->data_size = curr->lang->Info.Length;
    session->info->data = curr->lang->data;
    session->info->is32bit = curr->info->is32bit;

    session->info->stand_alone = WRENoInterface;
    session->info->symbol_table = curr->info->symbol_table;
    session->info->symbol_file = curr->info->symbol_file;

    session->tnode = curr->type;
    session->rnode = curr->res;
    session->lnode = curr->lang;
    session->rinfo = curr->info;

    session->hndl = WAccelStartEdit( session->info );

    if( session->hndl ) {
        WREInsertObject( &WREAccSessions, session );
    } else {
        WAccFreeAccelInfo( session->info );
        WRMemFree( session );
        session = NULL;
    }

    return( session );
}
Esempio n. 6
0
bool WREChangeMemFlags( void )
{
    WRECurrentResInfo   curr;
    HWND                parent;
    char                *type_name;
    uint_16             type_id;
    uint_16             mflags;
    HELP_CALLBACK       hcb;
    bool                ok;

    hcb = (HELP_CALLBACK)NULL;
    type_name = NULL;
    mflags = 0;
    type_id = 0;

    ok = WREGetCurrentResource( &curr );

    if( ok )  {
        if( !curr.type->Info.TypeName.IsName ) {
            type_id = curr.type->Info.TypeName.ID.Num;
        }
        type_name = WREGetResName( curr.res, type_id );
        parent = WREGetMainWindowHandle();
    }

    if( ok ) {
        hcb = (HELP_CALLBACK)MakeProcInstance( (FARPROC)WREHelpRoutine, WREGetAppInstance() );
        ok = (hcb != (HELP_CALLBACK)NULL);
    }

    if( ok ) {
        mflags = curr.lang->Info.MemoryFlags;
        ok = WRChangeMemFlags( parent, type_name, &mflags, hcb );
    }

    if( ok ) {
        curr.lang->Info.MemoryFlags = mflags;
    }

    if( hcb != (HELP_CALLBACK)NULL ) {
        FreeProcInstance( (FARPROC)hcb );
    }

    if( type_name != NULL ) {
        WRMemFree( type_name );
    }

    return( ok );
}
Esempio n. 7
0
bool WREQueryDeleteName( char *name )
{
    HWND        dialog_owner;
    DLGPROC     proc_inst;
    HINSTANCE   app_inst;
    INT_PTR     modified;

    dialog_owner = WREGetMainWindowHandle();
    app_inst = WREGetAppInstance();

    proc_inst = (DLGPROC)MakeProcInstance( (FARPROC)WREResDeleteProc, app_inst );

    modified = JDialogBoxParam( app_inst, "WREDeleteResource", dialog_owner, proc_inst, (LPARAM)name );

    FreeProcInstance( (FARPROC)proc_inst );

    return( modified != -1 && modified == IDOK );
}
Esempio n. 8
0
char *WREGetFileName( WREGetFileStruct *gf, DWORD flags, WREGetFileAction action )
{
    OPENFILENAME  wreofn;
    HWND          owner_window;
    Bool          ret;
    DWORD         error;
    int           len;
    char          fn_drive[_MAX_DRIVE];
    char          fn_dir[_MAX_DIR];
    char          fn_name[_MAX_FNAME];
    char          fn_ext[_MAX_EXT + 1];
    HINSTANCE     app_inst;

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

    owner_window = WREGetMainWindowHandle();
    app_inst = WREGetAppInstance();

    if( app_inst == NULL || owner_window == NULL ) {
        return( NULL );
    }

    if( gf->title != NULL ) {
        len = strlen( gf->title );
        if( len < _MAX_PATH ) {
            memcpy( wrefntitle, gf->title, len + 1 );
        } else {
            memcpy( wrefntitle, gf->title, _MAX_PATH );
            wrefntitle[_MAX_PATH - 1] = 0;
        }
    } else {
        wrefntitle[0] = 0;
    }

    if( gf->file_name != NULL && *gf->file_name != '\0' ) {
        _splitpath( gf->file_name, fn_drive, fn_dir, fn_name, fn_ext );
        if( *fn_drive != '\0' || *fn_dir != '\0' ) {
            _makepath( wre_initial_dir, fn_drive, fn_dir, NULL, NULL );
        }
        _makepath( wre_file_name, NULL, NULL, fn_name, fn_ext );
    } else {
        wre_file_name[0] = 0;
    }

    /* set the initial directory */
    if( *wre_initial_dir == '\0' ) {
        getcwd( wre_initial_dir, _MAX_PATH );
    }

#if !defined ( __NT__ )
    // CTL3D no longer requires this
    flags |= OFN_ENABLEHOOK;
#endif

    /* initialize the OPENFILENAME struct */
    memset( &wreofn, 0, sizeof( OPENFILENAME ) );

    /* fill in non-variant fields of OPENFILENAME struct */
    wreofn.lStructSize = sizeof( OPENFILENAME );
    wreofn.hwndOwner = owner_window;
    wreofn.hInstance = app_inst;
    wreofn.lpstrFilter = gf->filter;
    wreofn.lpstrCustomFilter = NULL;
    wreofn.nMaxCustFilter = 0;
    wreofn.nFilterIndex = WREFindFileFilterIndex( gf->filter );
    wreofn.lpstrFile = wre_file_name;
    wreofn.nMaxFile = _MAX_PATH;
    wreofn.lpstrFileTitle = wrefntitle;
    wreofn.nMaxFileTitle = _MAX_PATH;
    wreofn.lpstrInitialDir = wre_initial_dir;
    wreofn.lpstrTitle = wrefntitle;
    wreofn.Flags = flags;
    wreofn.lpfnHook = (LPVOID)MakeProcInstance( (LPVOID)WREOpenHookProc, app_inst );

#if 0
    wreofn.nFileOffset = 0L;
    wreofn.nFileExtension = 0L;
    wreofn.lpstrDefExt = NULL;
    wreofn.lCustData = NULL;
    wreofn.lpTemplateName = NULL;
#endif

    if( action == OPENFILE ) {
        ret = GetOpenFileName( (LPOPENFILENAME)&wreofn );
    } else if( action == SAVEFILE ) {
        ret = GetSaveFileName( (LPOPENFILENAME)&wreofn );
    } else {
        return( NULL );
    }

#ifndef __NT__
    if( wreofn.lpfnHook != NULL ) {
        FreeProcInstance( (FARPROC)wreofn.lpfnHook );
    }
#endif

    if( !ret ) {
        error = CommDlgExtendedError();
        if( error ) {
            WREDisplayErrorMsg( WRE_ERRORSELECTINGFILE );
        }
        return( NULL );
    } else {
        memcpy( wre_initial_dir, wre_file_name, wreofn.nFileOffset );
        if( wre_initial_dir[wreofn.nFileOffset - 1] == '\\' &&
            wre_initial_dir[wreofn.nFileOffset - 2] != ':' ) {
            wre_initial_dir[wreofn.nFileOffset - 1] = '\0';
        } else {
            wre_initial_dir[wreofn.nFileOffset] = '\0';
        }
        if( gf->save_ext ) {
            _splitpath( wre_file_name, NULL, NULL, NULL, fn_ext + 1 );
            if( fn_ext[1] != '\0' ) {
                fn_ext[0] = '*';
                WRESetFileFilter( fn_ext );
            } else {
                char *out_ext;
                out_ext = WREFindFileFilterFromIndex( gf->filter, wreofn.nFilterIndex );
                if( out_ext[2] != '*' ) {
                    strcat( wre_file_name, &out_ext[1] );
                }
            }
        }
    }

    UpdateWindow( WREGetMainWindowHandle() );

    return( WREStrDup( wre_file_name ) );
}