Ejemplo n.º 1
0
Bool WREAddCursorImageToData( WRECurrentResInfo *image, BYTE **data,
                              uint_32 *size, CURSORHOTSPOT *hotspot )
{
    int         hs_size; // size of hotspot info
    Bool        ok;

    ok = (image != NULL && image->info != NULL && image->info->info != NULL &&
          image->lang != NULL && data != NULL && size != NULL && hotspot != NULL);

    if( ok ) {
        if( image->lang->data == NULL ) {
            image->lang->data = WREGetCurrentResData( image );
            ok = (image->lang->data != NULL);
        }
    }

    if( ok ) {
        hs_size = sizeof( CURSORHOTSPOT );
        memcpy( hotspot, image->lang->data, hs_size );
        ok = WREAppendDataToData( data, size, (BYTE *)image->lang->data + hs_size,
                                  image->lang->Info.Length - hs_size );
    }

    return( ok );
}
Ejemplo n.º 2
0
Bool WREIsCorrectImageGroup( WRECurrentResInfo *group, uint_16 type, uint_16 id )
{
    RESICONHEADER       *ih;
    RESCURSORHEADER     *ch;
    int                 i;
    Bool                ok;

    ok = (group != NULL && group->info != NULL && group->info->info != NULL &&
          group->lang != NULL &&
          (type == (uint_16)RT_GROUP_ICON || type == (uint_16)RT_GROUP_CURSOR));

    if( ok ) {
        if( group->lang->data == NULL ) {
            group->lang->data = WREGetCurrentResData( group );
            ok = (group->lang->data != NULL);
        }
    }

    if( ok ) {
        ok = FALSE;
        if( type == (uint_16)RT_GROUP_ICON ) {
            ih = (RESICONHEADER *)group->lang->data;
            for( i = 0; !ok && i < ih->cwCount; i++ ) {
                ok = (id == (uint_16)ih->idEntries[i].wNameOrdinal);
            }
        } else {
            ch = (RESCURSORHEADER *)group->lang->data;
            for( i = 0; !ok && i < ch->cwCount; i++ ) {
                ok = (id == (uint_16)ch->cdEntries[i].wNameOrdinal);
            }
        }
    }

    return( ok );
}
Ejemplo n.º 3
0
bool WREClipBitmap( WRECurrentResInfo *curr, HWND main )
{
    HBITMAP     hbitmap;
    BYTE        *data;
    uint_32     dsize;
    bool        ok;

    data = NULL;
    hbitmap = (HBITMAP)NULL;

    ok = (curr != NULL && curr->type != NULL && curr->res != NULL && curr->lang != NULL);

    if( ok ) {
        data = (BYTE *)WREGetCurrentResData( curr );
        ok = (data != NULL);
    }

    if( ok ) {
        dsize = curr->lang->Info.Length;
        ok = WREAddBitmapFileHeader( &data, &dsize );
    }

    if( ok ) {
        hbitmap = WRBitmapFromData( data, NULL );
        ok = (hbitmap != (HBITMAP)NULL);
    }

    if( ok ) {
        ok = OpenClipboard( main ) != 0;
    }

    if( ok ) {
        EmptyClipboard();
        SetClipboardData( CF_BITMAP, hbitmap );
        CloseClipboard();
        hbitmap = (HBITMAP)NULL;
    }

    if( ok ) {
        WRRememberBitmapName( &curr->res->Info.ResName );
    }

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

    return( ok );
}
Ejemplo n.º 4
0
bool WREEditAccelResource( WRECurrentResInfo *curr )
{
    void                *rdata;
    bool                ok, rdata_alloc;
    WREAccelSession     *session;

    rdata = NULL;
    rdata_alloc = FALSE;

    ok = (curr != NULL && curr->lang != NULL);

    if( ok ) {
        session = WREFindLangAccelSession( curr->lang );
        if( session != NULL ) {
            WAccelBringToFront( session->hndl );
            return( TRUE );
        }
    }

    if( ok ) {
        if( curr->lang->data ) {
            rdata = curr->lang->data;
        } else if( curr->lang->Info.Length != 0) {
            ok = ((rdata = WREGetCurrentResData( curr )) != NULL);
            if( ok ) {
                rdata_alloc = TRUE;
            }
        }
    }

    if( ok ) {
        if( rdata_alloc ) {
            curr->lang->data = rdata;
        }
        ok = (WREStartAccelSession( curr ) != NULL);
    }

    if( rdata_alloc ) {
        WRMemFree( rdata );
        curr->lang->data = NULL;
    }

    return( ok );
}
Ejemplo n.º 5
0
Bool WREAddIconImageToData( WRECurrentResInfo *image, BYTE **data, uint_32 *size )
{
    Bool        ok;

    ok = (image != NULL && image->info != NULL && image->info->info != NULL &&
          image->lang != NULL && data != NULL && size != NULL);

    if( ok ) {
        if( image->lang->data == NULL ) {
            image->lang->data = WREGetCurrentResData( image );
            ok = (image->lang->data != NULL);
        }
    }

    if( ok ) {
        ok = WREAppendDataToData( data, size, image->lang->data,
                                  image->lang->Info.Length );
    }

    return( ok );
}
Ejemplo n.º 6
0
bool SaveObject( bool save_into )
{
    WRECurrentResInfo   curr;
    void                *rdata;
    bool                ok;

    WRESetWaitCursor( TRUE );

    rdata = NULL;

    ok = WREGetCurrentResource( &curr );

    if( ok ) {
        ok = (curr.lang->Info.Length != 0);
        if( !ok ) {
            WREDisplayErrorMsg( WRE_UPDATEBEFORESAVE1 );
        }
    }

    if( ok ) {
        ok = ((rdata = WREGetCurrentResData( &curr )) != NULL);
    }

    if( ok ) {
        if( save_into ) {
            ok = SaveObjectInto( &curr, rdata );
        } else {
            ok = SaveObjectAs( &curr, rdata );
        }
    }

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

    WRESetWaitCursor( FALSE );

    return( ok );
}
Ejemplo n.º 7
0
Bool WRECreateIconDataFromGroup( WRECurrentResInfo *group, BYTE **data, uint_32 *size )
{
    WResLangType        lt;
    WRECurrentResInfo   image;
    RESICONHEADER       *rih;
    ICONHEADER          *ih;
    uint_16             ord;
    uint_32             osize;
    int                 i;
    Bool                ok;

    ok = (group != NULL && group->info != NULL && group->info->info != NULL &&
          group->lang != NULL && data != NULL && size != NULL);

    if( ok ) {
        if( group->lang->data == NULL ) {
            group->lang->data = WREGetCurrentResData( group );
            ok = (group->lang->data != NULL);
        }
    }

    if( ok ) {
        image.info = group->info;
        rih = (RESICONHEADER *)group->lang->data;
        *size = sizeof( ICONHEADER );
        *size += sizeof( ICONDIRENTRY ) * (rih->cwCount - 1);
        *data = (BYTE *)WREMemAlloc( *size );
        ih = (ICONHEADER *)*data;
        ok = (*data != NULL);
    }

    if( ok ) {
        memcpy( ih, rih, sizeof( WORD ) * 3 );
    }

    if( ok ) {
        for( i = 0; ok && i < rih->cwCount; i++ ) {
            ord = (uint_16)rih->idEntries[i].wNameOrdinal;
            lt = group->lang->Info.lang;
            ok = WREFindImageId( &image, (uint_16)RT_ICON, ord, &lt );
            if( ok ) {
                osize = *size;
                ok = WREAddIconImageToData( &image, data, size );
                if( ok ) {
                    ih = (ICONHEADER *)*data;
                    ih->idEntries[i].bWidth = rih->idEntries[i].bWidth;
                    ih->idEntries[i].bHeight = rih->idEntries[i].bHeight;
                    ih->idEntries[i].bColorCount = rih->idEntries[i].bColorCount;
                    //ih->idEntries[i].wPlanes = rih->idEntries[i].wPlanes;
                    //ih->idEntries[i].wBitCount = rih->idEntries[i].wBitCount;
                    ih->idEntries[i].wPlanes = 0;
                    ih->idEntries[i].wBitCount = 0;
                    ih->idEntries[i].bReserved = 0;
                    ih->idEntries[i].dwBytesInRes = *size - osize;
                    ih->idEntries[i].dwImageOffset = osize;
                }
            }
        }
    }

    if( !ok ) {
        if( *data != NULL ) {
            WREMemFree( *data );
            *data = NULL;
        }
        *size = 0;
    }

    return( ok );
}
Ejemplo n.º 8
0
Bool WRECreateCursorDataFromGroup( WRECurrentResInfo *group, BYTE **data, uint_32 *size )
{
    WRECurrentResInfo   image;
    WResLangType        lt;
    RESCURSORHEADER     *rch;
    CURSORHEADER        *ch;
    CURSORHOTSPOT       hotspot;
    uint_16             ord;
    uint_32             osize;
    int                 i;
    Bool                ok;

    ok = (group != NULL && group->info != NULL && group->info->info != NULL &&
          group->lang != NULL && data != NULL && size != NULL);

    if( ok ) {
        if( group->lang->data == NULL ) {
            group->lang->data = WREGetCurrentResData( group );
            ok = (group->lang->data != NULL);
        }
    }

    if( ok ) {
        image.info = group->info;
        rch = (RESCURSORHEADER *)group->lang->data;
        *size = sizeof( CURSORHEADER );
        *size += sizeof( CURSORDIRENTRY ) * (rch->cwCount - 1);
        *data = (BYTE *)WREMemAlloc( *size );
        ch = (CURSORHEADER *)*data;
        ok = (*data != NULL);
    }

    if( ok ) {
        memcpy( ch, rch, sizeof( WORD ) * 3 );
    }

    if( ok ) {
        for( i = 0; ok && i < rch->cwCount; i++ ) {
            ord = (uint_16)rch->cdEntries[i].wNameOrdinal;
            lt = group->lang->Info.lang;
            ok = WREFindImageId( &image, (uint_16)RT_CURSOR, ord, &lt );
            if( ok ) {
                osize = *size;
                ok = WREAddCursorImageToData( &image, data, size, &hotspot );
                if( ok ) {
                    ch = (CURSORHEADER *)*data;
                    ch->cdEntries[i].bWidth = rch->cdEntries[i].bWidth;
                    ch->cdEntries[i].bHeight = rch->cdEntries[i].bHeight / 2;
                    ch->cdEntries[i].bColorCount = 0;
                    ch->cdEntries[i].bReserved = 0;
                    ch->cdEntries[i].wXHotspot = hotspot.xHotspot;
                    ch->cdEntries[i].wYHotspot = hotspot.yHotspot;
                    ch->cdEntries[i].dwBytesInRes = *size - osize;
                    ch->cdEntries[i].dwImageOffset = osize;
                }
            }
        }
    }

    if( !ok ) {
        if( *data != NULL ) {
            WREMemFree( *data );
            *data = NULL;
        }
        *size = 0;
    }

    return( ok );
}
Ejemplo n.º 9
0
WREClipData *WRECreateClipData( WRECurrentResInfo *curr )
{
    WREClipData *cdata;
    uint_32     cdata_size;
    BYTE        *rdata;
    uint_32     rdata_size;
    void        *name;
    uint_32     name_size;
    uint_16     type;
    bool        ok;

    cdata = NULL;
    rdata = NULL;
    name = NULL;

    ok = (curr != NULL && curr->type != NULL && curr->res != NULL && curr->lang != NULL);

    if( ok ) {
        type = 0;
        if( !curr->type->Info.TypeName.IsName ) {
            type = curr->type->Info.TypeName.ID.Num;
        }
        ok = (type != 0);
    }

    if( ok ) {
        ok = WRWResID2Mem( &curr->res->Info.ResName, &name, &name_size,
                           curr->info->is32bit );
    }

    if( ok ) {
        if( type == RESOURCE2INT( RT_GROUP_ICON ) ) {
            ok = WRECreateIconDataFromGroup( curr, &rdata, &rdata_size );
        } else if( type == RESOURCE2INT( RT_GROUP_CURSOR ) ) {
            ok = WRECreateCursorDataFromGroup( curr, &rdata, &rdata_size );
        } else {
            rdata = WREGetCurrentResData( curr );
            rdata_size = curr->lang->Info.Length;
            ok = (rdata != NULL && rdata_size != 0);
        }
    }

    if( ok ) {
        cdata_size = sizeof( WREClipData ) + name_size + rdata_size - 1;
        cdata = (WREClipData *)WRMemAlloc( cdata_size );
        ok = (cdata != NULL);
    }

    if( ok ) {
        cdata->clip_size = cdata_size;
        cdata->data_size = rdata_size;
        cdata->data_offset = cdata_size - rdata_size;
        cdata->type = type;
        cdata->memflags = curr->lang->Info.MemoryFlags;
        cdata->is32bit = curr->info->is32bit;
        memcpy( &cdata->name[0], name, name_size );
        memcpy( &cdata->name[name_size], rdata, rdata_size );
    } else {
        if( cdata != NULL ) {
            WRMemFree( cdata );
            cdata = NULL;
        }
    }

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

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

    return( cdata );
}