Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Saving Icons to file Collapse All
Subject Author Date
Raha Mohtasham Feb 21, 2008 - 7:09 AM

Hi,

Is there any method for saving Icons to a file?

CExtBitmap bmp;
HICON hIcon;

VERIFY( bmp.LoadBMP_Resource( MAKEINTRESOURCE( IDB_BITMAP1 ) ) );
bmp.AlphaColor( RGB(255,255,255), RGB(0,0,0), 0 );
bmp.SaveBMP_File("C:/TEST/BITMAP1");

hIcon = bmp.CreateHICON();
...
...SaveICON_File("C:/TEST/ICON1"); <------ SAVE the ICON

Thanks in advance

Technical Support Feb 25, 2008 - 4:29 AM

Prof-UIS allows you to save and load only .BMP images. The .ICO format is not supported. The advantage of using .BMP files instead of icons is that 32-bit BMP images are pefectly painted on any Windows OS starting from Windows 95 and Windows NT 4.0, which fully solves the compatibility issues. You can also use the CExtCmdIcon::Serialize() method in your project but this method does not work with the .ICO format. It simply serializes data of a CExtCmdIcon in a binary form.

Raha Mohtasham Feb 22, 2008 - 10:06 AM

CExtCmdIcon has a Serialize method. Is it possible to Save Icons to a file using this method?

If yes, why doesn’t the following code work?

CExtBitmap bmp;
HICON hIcon;

VERIFY( bmp.LoadBMP_Resource( MAKEINTRESOURCE( IDB_BITMAP1 ) ) );
bmp.AlphaColor( RGB(255,255,255), RGB(0,0,0), 0 );
bmp.SaveBMP_File("C:/TEST/BITMAP1");

hIcon = bmp.CreateHICON();
///////////////////////////////////////////////////////////Save the Icon to file/////////////
CExtCmdIcon cmdIcon;
CFile file;
cmdIcon.AssignFromHICON(hIcon, true);
if(file.Open("C:/TEST/ICON1", CFile::modeCreate | CFile::modeWrite))
{
CArchive ar(&file, CArchive::store);
cmdIcon.Serialize(ar);
ar.Close();
file.Close();
}
///////////////////////////////////////////

Technical Support Feb 21, 2008 - 10:11 AM

The CExtBitmap class allows you to save an image to a .BMP file. There is a CExtBitmapSkin class in ProfSkin library, which comes with Prof-UIS, that allows you to save an image to a .PNG file. Please note the CExtCmdIcon class is based on CExtBitmap class so an icon stores one or more bitmap images corresponding to different states of the icon. We do not support saving of .ICO files. Please use bitmaps instead of icons because the CExtBitmap class provides full support for loading, saving and painting 32-bit images with alpha channel even on Windows 95 and NT 4.