1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
//create the transparent icon handle
HICON hicon = (HICON)LoadImage(NULL, filename.c_str(), IMAGE_ICON, imageweight, imageheight, LR_LOADFROMFILE|LR_SHARED|LR_DEFAULTSIZE|LR_LOADTRANSPARENT);
//open the file for read the icon size
FILE *file=fopen(filename.c_str(),"rb");
//getting the icon size
char width,height;
fseek(file, 6, SEEK_SET);
fread(&width,1,1,file);
fread(&height,1,1,file);
//close the file
fclose(file);
//save the icon size
imageweight=width;
imageheight=height;
HBITMAP hbitmap=CreateBitmap(imageweight,imageheight,1,32,NULL);//create the bitmap with icon size
hdcimage = CreateCompatibleDC(NULL);//create a memory DC
SelectObject(hdcimage, hbitmap);//add the bitmap to memory DC
DrawIconEx(hdcimage,0,0,hicon,imageweight,imageheight,0,0,DI_NORMAL);//draw the icon to DC with right size
//seems the DrawIcon(), always, draw it with 32X32 size
|