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, < ) ) { 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, < ) ) { if( ilnode->data != NULL ) { MemFree( ilnode->data ); ilnode->data = NULL; } ok = WRRemoveLangNodeFromDir( info->dir, &itnode, &irnode, &ilnode ); } } } } if( data != NULL ) { MemFree( data ); } return( ok ); }
uint_16 WRAPI WRFindUnusedImageId( WRInfo *info, uint_16 start ) { WResLangNode *lnode; int found; int rollover; found = FALSE; rollover = FALSE; if( start == 0 ) { start = 1; } if( start == 1 ) { rollover = TRUE; } for( ;; ) { if( start > 0x7fff ) { if( !rollover ) { rollover = TRUE; start = 1; } else { break; } } if( !WRFindImageId( info, NULL, NULL, &lnode, RESOURCE2INT( RT_ICON ), start, NULL ) ) { if( !WRFindImageId( info, NULL, NULL, &lnode, RESOURCE2INT( RT_CURSOR ), start, NULL ) ) { found = TRUE; break; } } start++; } if( !found ) { start = 0; } return( start ); }
Bool WREFindImageId( WRECurrentResInfo *image, uint_16 type, uint_16 id, WResLangType *ltype ) { Bool ok; ok = (image != NULL && image->info != NULL); if( ok ) { ok = WRFindImageId( image->info->info, &image->type, &image->res, &image->lang, type, id, ltype ); } if( !ok ) { image->type = NULL; image->lang = NULL; image->lang = NULL; } return( ok ); }
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, < ); 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 ); }
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, < ); 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 ); }