Sky Software Homepage LogicNP Software Knowledge Base And FAQ

 
Contact Product Support    SearchSearch      Subscribe to the RSS feed for this forum

HOWTO : Use icons mode (NSEIEM_Icons) to specify different icons for items.

 
Subscribe to the RSS feed for this forum  Forum Index -> EZNamespaceExtensionsMFC
View previous topic :: View next topic  
Author Message
Support



Joined: 18 Jul 2005
Posts: 731

Posted: Tue Jun 24, 2008 5:57 am    Post subject: HOWTO : Use icons mode (NSEIEM_Icons) to specify different icons for items.

To use icons mode (NSEIEM_Icons) to specify icons for items, override the GetIconFileAndIndex and GetIcons methods of the namespace extension.

In the GetIconFileAndIndex method, set the iconExtractMode member to NSEIEM_Icons. This causes EZNamespaceExtensions to later call the GetIcons function which is used to retrieve the actual icons. The iconFile and iconIndex members must also be set to a value which uniquely identifies the icon (used as a key). Windows Explorer avoids multiple calls to the GetIcons function if the same key is specified.

The following code (adapted from the FileSystemBrowser sample) displays 3 different icons for the folders depending upon length of the display name of the folder.

[C++]
void CFolderItem::GetIconFileAndIndex(CGetIconFileAndIndexEventArgs& e)
{
// Causes GetIcons function to be called.
e.iconExtractMode = NSEIEM_Icons;

//name is the display name of the folder that we will be using in the code
if(name.GetLength() < 5)
{
// iconIndex and iconFile together uniquely identify the icon
e.iconIndex = 0;
e.iconFile = "MyNSE";
}
else if(name.GetLength() < 10)
{
// iconIndex and iconFile together uniquely identify the icon
e.iconIndex = 1;
e.iconFile = "MyNSE";
}
else
{
// iconIndex and iconFile together uniquely identify the icon
e.iconIndex = 2;
e.iconFile = "MyNSE";
}
}

void CFolderItem::GetIcons(CGetIconsEventArgs& e)
{
if(name.GetLength() < 5)
{
//Set to the desired icon
e.hLargeIcon = (HICON)LoadImage(NULL,"C:\\small.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE);
e.hSmallIcon = (HICON)LoadImage(NULL,"C:\\large.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE);
}
else if(name.GetLength() < 10)
{
e.hLargeIcon = (HICON)LoadImage(NULL,"C:\\medium.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE);
e.hSmallIcon = (HICON)LoadImage(NULL,"C:\\large.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE);
}
else
{
e.hLargeIcon = (HICON)LoadImage(NULL,"C:\\large.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE);
e.hSmallIcon = (HICON)LoadImage(NULL,"C:\\large.ico",IMAGE_ICON,0,0,LR_LOADFROMFILE);
}
}
Back to top
Display posts from previous:   
Forum Index -> EZNamespaceExtensionsMFC All times are GMT
Page 1 of 1

 
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group