Text File with Custom Icon

As far as I recall / understand, to set a custom icon on a file, we have to use BinaryStream (*).

Am I right ?

  • BinaryStream vs TextInputStream / TextOutputStream.
    Files created with TextOutputStream are always of type text.
    BTW: I forgot to check the Windows status for that. Ideas ?

no, icon is based normally on file extension nowadays.

Be do have functions in MBS plugin for adding per file custom icons.

[quoteFiles created with TextOutputStream are always of type text.][/quote]
Also incorrect. You may set those files to any type you wish.

This is OK for me, but unless I use BinaryStream to save a file (even a text file), I never was able to set a custom icon to it. I get the OS X text icon with my custom extension, but this is IMHO not a custom icon.

Am I still wrong ?

Just because you use textoutputstream to save a file does not mean it must have an extension of .txt. Define a fileType of Schwarz with the extension .emile, assign a custom icon to that file type, and set the name of your document created with textoutputstream to “MyFile.emile”

Roger:

last time I’ve done that, it did not worked. All I got was a Text icon and the file extension above it at 2/3 of the height -to the bottom).

That is why I asked here (with a large delay)…

BTW: that is on OS X.

Now that my MacBook Pro is on repair, I will check the situation on Windows 8.1.

PS: I changed the file extension two or three times just to be sure (both in the project and in the file): that was what I got.

Creating different file types other than .txt definitely works. I have no way of knowing what you may have done incorrectly.

Part one of the sentence:
Yes, of course, but the question is to set it my (or yours) custom icon on that (non .txt file extension, .emile for example).
I will check (on Windows 8.1)

Part II of the sentence:
Yes, you are right too. I will create a simple project to demonstrate that.

I am waiting foer a download to end and so I created a simple project with a file type and a PushButton with the code below:

Sub Action() Dim t As TextOutputStream Dim f As FolderItem f = GetSaveFolderItem("", "CreateExample.emile") If f <> Nil Then t = TextOutputStream.Create(f) t.WriteLine("TextField1.Text") t.Close End If End Sub

The code comes from the docs (textoutputstream) with two changes:

I replaced txt with emile.
I do not add a TextField, so I changed the WriteLine.ype with a custom icon and .emile as the file extension.

While running in the IDE: the created file have the set extension, but no special (not a TEXT icon, nor my custom icon) was set on my file.

Since I do not created the application, the test is not really valid, but it does a difference between OS X and Windows. I tried to refresh the folder contents

Nota: the file extension (.emile) appears, unlike all the other files on that folder.

I checked at home with the created application and it did not worked.

I shut down the Windows 8.1 machine, boot it again and get the same result. I run the application opnce more, create another file and get the same file without my custom icon.

I will share the (simple) project tomorrow. (I forget it at home).

Setting a file icon in Windows is a registry function. Or with declares (that in turn update the registry). You usually do that be declaring what the default program is that opens the file. That program’s icon is used for the file.

Note: if the extension is shown it means that Windows doesn’t recognize the extension (you haven’t declared it in the registry).

Depends on the settings in the folders options. One can display all extensions, even known. We do not know what Emile may have chosen.

Check http://answers.microsoft.com/en-us/windows/forum/windows_7-files/create-a-file-type-in-win7-and-assign-a-new-action/a72de659-0683-e011-9b4b-68b599b31bf5

I completed the example before getting your answers. So, forgive me for not reading them - yet -.

Here is the Project link.

Now, I will read your answers and react - eventually - later (below).

PS: since yesterday early in the morning, I do not have for sometimes an OS X machine. So this example was created on Windows 8 (with all sorts of difficulties).
What is the learning curve time for a computer newbie using Windows 8 vs OS X ?

[quote=146949:@Tim Hare]Setting a file icon in Windows is a registry function. Or with declares (that in turn update the registry). You usually do that be declaring what the default program is that opens the file. That program’s icon is used for the file.

Note: if the extension is shown it means that Windows doesn’t recognize the extension (you haven’t declared it in the registry).[/quote]
Thank you Tim for your answer.

Part 1: a $1,000 software does not provide that natively ? Incredible. And nothing in the documentation ! I can’t believe that :frowning:

Part 2: That is what I understand: the project file stands in the same folder (so three items inside that folder and two file extensions visibles).

Thank you Michel for your kind answer.

I do not choose anything (read: I do not change Windows 8.1 settings that are “do not show the file extensions”).

Thank you too for the link. BUT, as I wrote earlier, this HAVE to be in the docs, somewhere (if not already: I cannot search for something I do not know, before now).

Talking about documentation: I searched the Xojo release notes for version 2014r2.1, but I do not found them (WINDOWS). THey do not seems to be in the Windows release (unlike in OS X dmg).
Yes, I will install Feedback and get it from there or from the docs web site.

BTW: reading Michel link and RegistryItem does not really help me.

I will wait this afternoon (14:00 ?) and read both pages again.

As far as I remember that’s what installers are for. They register your app, extension, and document icon with the system by modifying the registry accordingly.

Actually, he did indicate that.

And as Markus mentioned, this is a function of your installer on Windows, not something your app should do.

How old Windows COmpile is on REALbasic 2 ? 18 years ? So this is the first time ever that I read that.

I checked (as I could) the pdfs yesterday, a bit of examples, etc. but never found that information.

Even the page on Innosetup does not talk about that.

I will issue a new conversation about these past three days of Xojo for WIndows use. A story of pain and tears.

Thank you all for your comments.

To be honest, it’s not a very common thing to do on Windows. But the innosetup instructions are here.