FsExtractCustomIcon

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
abain
Junior Member
Junior Member
Posts: 6
Joined: 2003-11-03, 06:12 UTC

FsExtractCustomIcon

Post by *abain »

I am currently having problems with FsExtractCustomIcon.

No matter what I do I can not get the icon to change. Does anyone have an example in C++?

My current code. I tried using a predefined icon to see if that would work. If I change it to IDI_ICON1 which is defined in the fsplugin sample I get a compiler error. Saying undeclared identifier. I am not very good at C++ so any help would be greatly appreciated.

int __stdcall FsExtractCustomIcon(char* RemoteName,int ExtractFlags,HICON* TheIcon)
{
HICON myIcon = NULL;
if (stricmp(RemoteName+pluginrootlen, "A:\\") == 0)
{
myIcon = LoadIcon(NULL, IDI_APPLICATION);
TheIcon = &myIcon;
return FS_ICON_EXTRACTED;
}
return FS_ICON_USEDEFAULT;
}
Thanks,
Austin
abain
Junior Member
Junior Member
Posts: 6
Joined: 2003-11-03, 06:12 UTC

Got it working

Post by *abain »

I finally got it working. I needed to change the DLLMain to

HINSTANCE theDll = NULL;
BOOL APIENTRY DllMain( HINSTANCE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
theDll = hModule;
return TRUE;
}

I changed HANDLE hModule to HINSTANCE hModule.
Then I stroed the hModule into theDll varible.

Then I used myIcon = LoadIcon(theDll, MAKEINTRESOURCE(IDI_ICON2)); to get the icon.

Could someone validate that this is the correct way to do this?

Thanks,

Austin
User avatar
André Martin
Senior Member
Senior Member
Posts: 245
Joined: 2003-02-05, 15:46 UTC
Location: Dresden, Germany

Post by *André Martin »

Absolutely correct, but I prefer the following:

Code: Select all

if(ExtractFlags&FS_ICONFLAG_SMALL)
*TheIcon = LoadImage(ApplicationInstance, "ICON", IMAGE_ICON, 16, 16, 0);
else *TheIcon = LoadImage(ApplicationInstance, "ICON",  IMAGE_ICON, 32, 32, 0);
Browse the web with the HTTP SmartBrowserPlugin
Check your mails with the POP3/SMTP EmailPlugin!
abain
Junior Member
Junior Member
Posts: 6
Joined: 2003-11-03, 06:12 UTC

Post by *abain »

André,

Thanks for the example. However when I compile the example I get an error saying cannot convert from 'HANDLE' to 'HICON'.

Also, do you get the ApplicationInstance the way I do in the DLLMain or do you get it a different way?

Thanks again for the help.

Austin
abain
Junior Member
Junior Member
Posts: 6
Joined: 2003-11-03, 06:12 UTC

Post by *abain »

The code that actually worked is below. I could not get it to work without the MAKEINTRESOURCE and casting to HICON.

I could not get it to work without these changes to André's sample.

ApplicationInstance comes from DLLMain. Is there another way to get the ApplicationInstance?

Code: Select all

if(ExtractFlags&FS_ICONFLAG_SMALL) 
*TheIcon = (HICON) LoadImage(ApplicationInstance, MAKEINTRESOURCE(IDI_ICON2), IMAGE_ICON, 16, 16, 0); 
else *TheIcon = (HICON) LoadImage(ApplicationInstance, MAKEINTRESOURCE(IDI_ICON2),  IMAGE_ICON, 32, 32, 0);
Thanks,

Austin
User avatar
André Martin
Senior Member
Senior Member
Posts: 245
Joined: 2003-02-05, 15:46 UTC
Location: Dresden, Germany

Post by *André Martin »

The "absolute correct" should imply that I get the handle the same way you do (via DLLMain) :-)
Some compilers require a casting...
abain
Junior Member
Junior Member
Posts: 6
Joined: 2003-11-03, 06:12 UTC

Post by *abain »

André,

Thanks that helps a lot. I'm new to C++ programming and getting a little lost in the windows API at the same time. Thanks for the help.

Austin
Post Reply