youpiyoyo
Messages postés539Date d'inscriptionvendredi 6 juin 2003StatutMembreDernière intervention14 juillet 2010
-
24 juil. 2004 à 13:07
robinfinity
Messages postés1Date d'inscriptionmercredi 29 septembre 2004StatutMembreDernière intervention29 septembre 2004
-
29 sept. 2004 à 15:11
je cherche a mettre une icone dans une resource le probleme c ke j'ouvre l'ico comme ca
HICON Ico=ExtractIcon(MainhInstance,szFile,0);
ou szFile est ouvert par GetOpenFileName
bref dans mon
result = UpdateResource(hUpdateRes, // update resource handle
RT_ICON, // change dialog box resource
"ico", // dialog box name
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), // neutral language
Ico, // ptr to resource info
SizeofResource(hExe, hRes)); // size of resource info.
dans msdn il est spécifié ke LPVOID lpData, "Note that this is the raw binary data stored in the executable file, not the data provided by LoadIcon, LoadString, or other resource-specific load functions. All data containing strings or text must be in Unicode format; lpData must not point to ANSI data.
//le reste de ton code
result = UpdateResource(hUpdateRes, // update resource handle
RT_ICON, // change dialog box resource
"ico", // dialog box name
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), // neutral language
lpRes, // ptr to resource info
SizeofResource(hMod, hres)); // size of resource info.
FreeLibrary(hMod);
robinfinity
Messages postés1Date d'inscriptionmercredi 29 septembre 2004StatutMembreDernière intervention29 septembre 2004 29 sept. 2004 à 15:11
Hi!
Sorry for writing in English, but I not good at all in French, even if I can understand a little bit of it...
The above code is almost okay to pass binary data from an icon to resource, but the problem is that you don't need to pass all the data from an ICO to the resource.
I have an icon file which has only one image, size 16x16, 256 colors, and I realized that the "good" data begins at the 22th byte in the ico file, so my code looks like this:
This will not work for other icons than size 16x16, 256 colors, or icon files containing multiple formats.
To find the correct code, I did a very "ugly" thing: made a loop from x=1 to pos (the size of the icon file) and took (pos-x) bytes from (ico+x) and copied them to the resource.
UpdateResource((HMODULE)hUpd, RT_ICON,MAKEINTRESOURCE(1), 0x409, (LPBYTE)(ico+x), pos-x);
Than created a sepparate exe file (opened the modified exe binary, and created a new binary file to copy its contents) for each iteration (x.exe) and than verified which one has a good icon :))