Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » FileSel&FileList, Path » FileSel and international files problem when getting icon image
FileSel and international files problem when getting icon image [message #18542] Tue, 07 October 2008 13:17 Go to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello all

I have found a problem when reading international file names. In these cases the icon is not readed.

Searching around I have found that the struct FileIconMaker has a member declared String file. If the file name has non english characters the function virtual Image Make() does not work.

To solve it I simply change this in FileSel.cpp:

for(int i = 0; i < 2; i++) {
     SHFILEINFO info;
     SHGetFileInfo(file, dir ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL, &info, sizeof(info),

with this;

WString wfile = file.ToWString();
for(int i = 0; i < 2; i++) {
     SHFILEINFOW info;
     SHGetFileInfo(wfile, dir ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL, &info, sizeof(info),

and it works.

Best regards
Koldo


Best regards
Iñaki
Re: FileSel and international files problem when getting icon image [message #18753 is a reply to message #18542] Sun, 19 October 2008 22:48 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Tue, 07 October 2008 07:17

Hello all

I have found a problem when reading international file names. In these cases the icon is not readed.

Searching around I have found that the struct FileIconMaker has a member declared String file. If the file name has non english characters the function virtual Image Make() does not work.

To solve it I simply change this in FileSel.cpp:

for(int i = 0; i < 2; i++) {
     SHFILEINFO info;
     SHGetFileInfo(file, dir ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL, &info, sizeof(info),

with this;

WString wfile = file.ToWString();
for(int i = 0; i < 2; i++) {
     SHFILEINFOW info;
     SHGetFileInfo(wfile, dir ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL, &info, sizeof(info),

and it works.

Best regards
Koldo


Well, first I have applied this patch, but I am afraid this would not work with Win98.

Could you try this first?

		for(int i = 0; i < 2; i++) {
			SHFILEINFO info;
			SHGetFileInfo(ToSystemCharset(file), dir ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL,
			              &info, sizeof(info),
			              SHGFI_ICON|SHGFI_SMALLICON|(exe ? 0 : SHGFI_USEFILEATTRIBUTES));



Mirek

[Updated on: Sun, 19 October 2008 22:50]

Report message to a moderator

Re: FileSel and international files problem when getting icon image [message #18760 is a reply to message #18542] Mon, 20 October 2008 09:14 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello luzr

I have tried both in XP and:

- The option with SHFILEINFO and ToSystemCharset(file) works well with a folder named "Ñandú", but it does not with another named "印经济" (sorry, this is chinese and I do not have any idea about its meaning...)

- The other one with SHFILEINFOW does work in both cases.

Best regards
Koldo



Best regards
Iñaki
Re: FileSel and international files problem when getting icon image [message #18761 is a reply to message #18760] Mon, 20 October 2008 10:42 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
BTW, in what sense exactly it "does not work"?

AFAIK, for the most part, only the file extension matters. The exception to this rule is .exe and .ico files.

Mirek
Re: FileSel and international files problem when getting icon image [message #18784 is a reply to message #18542] Mon, 20 October 2008 22:49 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello luzr

I mean that it gets or not the folder icon. With SHFILEINFOW seems to always take the right folder icon, but with SHFILEINFO not.

Perhaps if somebody with "non european" charset may test it, it would be better as I am using an XP system with "european" charset and my system perhaps is not working properly with the chinese charset.

Best regards
Koldo


Best regards
Iñaki
Re: FileSel and international files problem when getting icon image [message #18788 is a reply to message #18542] Tue, 21 October 2008 07:00 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Hello luzr

I have seen that with the last version with SHFILEINFO the right icon of a file called "印经济" can be readed, but if instead, "印经济" is a folder, the folder icon can be got with GetFileIcon(path, true), but not with GetFileIcon(path, true, true) as it is in the sources.

I thought that a solution would be changing NativePathIcon to something like:
#if defined(PLATFORM_WIN32)
	if (IsDrive(path) && IsSpecialFolder(path))
		return GetFileIcon(path, true, true);
	else
		return GetFileIcon(path, folder);
#endif

where IsSpecialFolder(path) would be true in folders with icons like Desktop but, if I where in Taiwan, could I get the taiwanese Desktop icon ?

Best regards
Koldo


Best regards
Iñaki
Re: FileSel and international files problem when getting icon image [message #18805 is a reply to message #18784] Wed, 22 October 2008 23:37 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Mon, 20 October 2008 16:49

Hello luzr

I mean that it gets or not the folder icon. With SHFILEINFOW seems to always take the right folder icon, but with SHFILEINFO not.

Perhaps if somebody with "non european" charset may test it, it would be better as I am using an XP system with "european" charset and my system perhaps is not working properly with the chinese charset.



This is not unlikely. In CJK environment, folder names are encoded using MBCS (I mean, if you do not use SHFILEINFOW). ToSystemCharset performs necessarry conversions.

Mirek
Re: FileSel and international files problem when getting icon image [message #18806 is a reply to message #18788] Wed, 22 October 2008 23:39 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Tue, 21 October 2008 01:00

Hello luzr

I have seen that with the last version with SHFILEINFO the right icon of a file called "印经济" can be readed, but if instead, "印经济" is a folder, the folder icon can be got with GetFileIcon(path, true), but not with GetFileIcon(path, true, true) as it is in the sources.

I thought that a solution would be changing NativePathIcon to something like:
#if defined(PLATFORM_WIN32)
	if (IsDrive(path) && IsSpecialFolder(path))
		return GetFileIcon(path, true, true);
	else
		return GetFileIcon(path, folder);
#endif

where IsSpecialFolder(path) would be true in folders with icons like Desktop but, if I where in Taiwan, could I get the taiwanese Desktop icon ?

Best regards
Koldo


I do not quite understand this Smile Is this tested? Should I replace the current code?

Of course, there are always two correct solutions:

- introduce another .dli and call W or A variant based on system (W in WinNT)

- finally trash Win98....

I would really be happy to finally end support for Win98. Unfortunately, there was still demand for it, believe or not.

Mirek
Re: FileSel and international files problem when getting icon image [message #18807 is a reply to message #18806] Thu, 23 October 2008 00:20 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3354
Registered: August 2008
Senior Veteran
Well... perhaps I have gone too far

I have tested the code with this but it would be better if somebody
from Greece, China, etc could test it and give us their opinion.

index.php?t=getfile&id=1457&private=0

If not I think that the source is enough ok!

Best regards
Koldo
  • Attachment: Desktop.jpg
    (Size: 9.75KB, Downloaded 731 times)


Best regards
Iñaki
Re: FileSel and international files problem when getting icon image [message #18809 is a reply to message #18807] Thu, 23 October 2008 09:18 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Wed, 22 October 2008 18:20

Well... perhaps I have gone too far

I have tested the code with this but it would be better if somebody
from Greece, China, etc could test it and give us their opinion.

index.php?t=getfile&id=1457&private=0

If not I think that the source is enough ok!

Best regards
Koldo


Well, really...

Originally we were not loading any icons from host. And getting these icons was really meant only for fileselector...

Is that really such trouble if FileSel displays generic folder icon in some cases where there is non-generic variant?

That said, I believe this should really be fixed. But maybe we can finally drop Win98 support this year (10 years is enough, is not it? Smile and the problem will be solved without much effort...

Mirek
Previous Topic: knowing extinsion and name
Next Topic: Problem with FileSel called from menu
Goto Forum:
  


Current Time: Thu Mar 28 13:08:39 CET 2024

Total time taken to generate the page: 0.01187 seconds