Exemplo n.º 1
0
bool WRAPI WRAddIconImageToData( WRInfo *info, WResLangNode *lnode,
                                    BYTE **data, uint_32 *size )
{
    BYTE        *ldata;
    bool        ok;

    ldata = NULL;

    ok = (info != NULL && lnode != NULL && data != NULL && size != NULL);

    if( ok ) {
        ldata = WRCopyResData( info, lnode );
        ok = (ldata != NULL);
    }

    if( ok ) {
        ok = WRAppendDataToData( data, size, ldata, lnode->Info.Length );
    }

    if( ldata != NULL ) {
        MemFree( ldata );
    }

    return( ok );
}
Exemplo n.º 2
0
static char *WREFindDLGInclude( WRInfo *info )
{
    WResTypeNode        *tnode;
    WResResNode         *rnode;
    WResLangNode        *lnode;
    WResLangType        lang;
    char                *include;
    bool                ok;

    include = NULL;
    ok = (info != NULL);

    if( ok ) {
        tnode = WRFindTypeNode( info->dir, (uint_16)(pointer_int)RT_RCDATA, NULL );
        ok = (tnode != NULL);
    }

    if( ok ) {
        rnode = WRFindResNode( tnode, 0, "DLGINCLUDE" );
        ok = (rnode != NULL);
    }

    if( ok ) {
        lang.lang = DEF_LANG;
        lang.sublang = DEF_SUBLANG;
        lnode = WRFindLangNodeFromLangType( rnode, &lang );
        ok = (lnode != NULL);
    }

    if( ok ) {
        include = (char *)WRCopyResData( info, lnode );
    }

    return( include );
}
Exemplo n.º 3
0
bool WRAPI WRAddCursorImageToData( WRInfo *info, WResLangNode *lnode,
                                      BYTE **data, uint_32 *size, CURSORHOTSPOT *hotspot )
{
    BYTE        *ldata;
    size_t      hs_size; // size of hotspot info
    bool        ok;

    ldata = NULL;

    ok = (info != NULL && lnode != NULL && data != NULL && size != NULL && hotspot != NULL);

    if( ok ) {
        ldata = WRCopyResData( info, lnode );
        ok = (ldata != NULL);
    }

    if( ok ) {
        hs_size = sizeof( CURSORHOTSPOT );
        memcpy( hotspot, ldata, hs_size );
        ok = WRAppendDataToData( data, size, ldata + hs_size, lnode->Info.Length - (uint_32)hs_size );
    }

    if( ldata != NULL ) {
        MemFree( ldata );
    }

    return( ok );
}
Exemplo n.º 4
0
bool WRAPI WRDeleteGroupImages( WRInfo *info, WResLangNode *lnode, uint_16 type )
{
    WResLangType        lt;
    WResTypeNode        *itnode;
    WResResNode         *irnode;
    WResLangNode        *ilnode;
    void                *data;
    RESICONHEADER       *ih;
    RESCURSORHEADER     *ch;
    int                 i;
    uint_16             ord;
    bool                ok;

    ok = (info != NULL && lnode != NULL && (type == RESOURCE2INT( RT_GROUP_ICON ) || type == RESOURCE2INT( RT_GROUP_CURSOR )));

    if( ok ) {
        data = WRCopyResData( info, lnode );
        ok = (data != NULL);
    }

    if( ok ) {
        if( type == RESOURCE2INT( RT_GROUP_ICON ) ) {
            ih = (RESICONHEADER *)data;
            for( i = 0; ok && i < ih->cwCount; i++ ) {
                ord = (uint_16)ih->idEntries[i].wNameOrdinal;
                lt = lnode->Info.lang;
                if( WRFindImageId( info, &itnode, &irnode, &ilnode, RESOURCE2INT( RT_ICON ), ord, &lt ) ) {
                    if( ilnode->data != NULL ) {
                        MemFree( ilnode->data );
                        ilnode->data = NULL;
                    }
                    ok = WRRemoveLangNodeFromDir( info->dir, &itnode, &irnode, &ilnode );
                }
            }
        } else {
            ch = (RESCURSORHEADER *)data;
            for( i = 0; ok && i < ch->cwCount; i++ ) {
                ord = (uint_16)ch->cdEntries[i].wNameOrdinal;
                lt = lnode->Info.lang;
                if( WRFindImageId( info, &itnode, &irnode, &ilnode, RESOURCE2INT( RT_CURSOR ), ord, &lt ) ) {
                    if( ilnode->data != NULL ) {
                        MemFree( ilnode->data );
                        ilnode->data = NULL;
                    }
                    ok = WRRemoveLangNodeFromDir( info->dir, &itnode, &irnode, &ilnode );
                }
            }
        }
    }

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

    return( ok );
}
Exemplo n.º 5
0
void *WREGetCurrentResData( WRECurrentResInfo *curr )
{
    void       *rdata;

    rdata = NULL;
    if( curr != NULL && curr->info != NULL && curr->lang != NULL ) {
        rdata = WRCopyResData( curr->info->info, curr->lang );
    }

    return( rdata );
}
Exemplo n.º 6
0
/*
 * readInResourceFile
 */
static bool readInResourceFile( char *fullname )
{
    BYTE                *data;
    uint_32             dsize;
    WRInfo              *info;
    WRSelectImageInfo   *sii;
    WPI_PROC            cb;
    bool                ok;

    info = NULL;
    sii = NULL;
    data = NULL;
    ok = (fullname != NULL);

    if( ok ) {
        info = WRLoadResource( fullname, WR_DONT_KNOW );
        ok = (info != NULL);
    }

    if( ok ) {
        cb = _wpi_makeprocinstance( (WPI_PROC)IEHelpCallBack, Instance );
        sii = WRSelectImage( HMainWindow, info, cb );
        _wpi_freeprocinstance( cb );
        ok = (sii != NULL && sii->lnode != NULL);
    }

    if( ok ) {
        if( sii->type == (uint_16)(pointer_int)RT_BITMAP ) {
            imgType = BITMAP_IMG;
            data = WRCopyResData( info, sii->lnode );
            dsize = sii->lnode->Info.Length;
            ok = (data != NULL);
            if( ok ) {
                ok = WRAddBitmapFileHeader( &data, &dsize );
            }
        } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_CURSOR ) {
            imgType = CURSOR_IMG;
            ok = WRCreateCursorData( info, sii->lnode, &data, &dsize );
        } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_ICON ) {
            imgType = ICON_IMG;
            ok = WRCreateIconData( info, sii->lnode, &data, &dsize );
        } else {
            imgType = UNDEF_IMG;
            ok = false;
        }
    }

    if( ok ) {
        if( sii->type == (uint_16)(pointer_int)RT_BITMAP ) {
            ok = ReadBitmapFromData( data, fullname, info, sii->lnode );
        } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_CURSOR ) {
            ok = ReadCursorFromData( data, fullname, info, sii->lnode );
        } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_ICON ) {
            ok = ReadIconFromData( data, fullname, info, sii->lnode );
        }
    }

    if( sii != NULL ) {
        WRFreeSelectImageInfo( sii );
    }

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

    return( ok );

} /* readInResourceFile */
Exemplo n.º 7
0
bool WRAPI WRCreateIconData( WRInfo *info, WResLangNode *lnode,
                                BYTE **data, uint_32 *size )
{
    WResLangNode        *ilnode;
    BYTE                *ldata;
    RESICONHEADER       *rih;
    ICONHEADER          *ih;
    WResLangType        lt;
    uint_16             ord;
    uint_32             osize;
    int                 i;
    bool                ok;

    ok = (info != NULL && lnode != NULL && data != NULL && size != NULL);

    if( ok ) {
        ldata = WRCopyResData( info, lnode );
        ok = (ldata != NULL);
    }

    if( ok ) {
        rih = (RESICONHEADER *)ldata;
        *size = sizeof( ICONHEADER );
        *size += sizeof( ICONDIRENTRY ) * (rih->cwCount - 1);
        *data = (BYTE *)MemAlloc( *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 = lnode->Info.lang;
            ok = WRFindImageId( info, NULL, NULL, &ilnode, RESOURCE2INT( RT_ICON ), ord, &lt );
            if( ok ) {
                osize = *size;
                ok = WRAddIconImageToData( info, ilnode, 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 ) {
            MemFree( *data );
            *data = NULL;
        }
        *size = 0;
    }

    return( ok );
}
Exemplo n.º 8
0
bool WRAPI WRCreateCursorData( WRInfo *info, WResLangNode *lnode,
                                  BYTE **data, uint_32 *size )
{
    WResLangNode        *ilnode;
    BYTE                *ldata;
    RESCURSORHEADER     *rch;
    CURSORHEADER        *ch;
    CURSORHOTSPOT       hotspot;
    WResLangType        lt;
    uint_16             ord;
    uint_32             osize;
    int                 i;
    bool                ok;

    ok = (info != NULL && lnode != NULL && data != NULL && size != NULL);

    if( ok ) {
        ldata = WRCopyResData( info, lnode );
        ok = (ldata != NULL);
    }

    if( ok ) {
        rch = (RESCURSORHEADER *)ldata;
        *size = sizeof( CURSORHEADER );
        *size += sizeof( CURSORDIRENTRY ) * (rch->cwCount - 1);
        *data = (BYTE *)MemAlloc( *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 = lnode->Info.lang;
            ok = WRFindImageId( info, NULL, NULL, &ilnode, RESOURCE2INT( RT_CURSOR ), ord, &lt );
            if( ok ) {
                osize = *size;
                ok = WRAddCursorImageToData( info, ilnode, 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 ) {
            MemFree( *data );
            *data = NULL;
        }
        *size = 0;
    }

    return( ok );
}