Associate file types

Does anyone know or is there documentation how to associate file extensions to my application on mac, windows and linux?
Not with an external program, but from inside the application itself.

Thank you.

In the Insert Menu,
File Type Set

Then: FolderItem.MacType

Example (from doc):

dim f As New folderitem
f = GetOpenFolderItem(“text/plain”)

if f.MacType <> “” Then
MsgBox f.MacType
Else
MsgBox “MacType is not specified.”
End If

Is it enough ?

[quote=40655:@Emile Schwarz]In the Insert Menu,
File Type Set

Then: FolderItem.MacType

Example (from doc):

dim f As New folderitem
f = GetOpenFolderItem(“text/plain”)

if f.MacType <> “” Then
MsgBox f.MacType
Else
MsgBox “MacType is not specified.”
End If

Is it enough ?[/quote]

That is not what I meant.

Associating a file extension to your app, means when you click on a file with the associated extension in lets says Finder or Explorer that your app starts and the clicked file is usable through the OpenDocument Handler in your app.

This is related to drag and drop (a file type to the application / dock / whatever).

OK, so the other answer is to check in the Default Platform / Application.
TutorialDesktop.pdf, page 33 (Section 3: Building a Standalone App)
See the Choose… button page 34.

Have you created at least one File Type Set ?

The other location (to put code in) is in App.DropObject (I think):
http://documentation.xojo.com/index.php/Application.OpenDocument_event

You can drop more than one file onto the application Icon and check the documentation to learn how to deal with all files.

Also, read:
UserGuide-Fundamentals.pdf → Section 1: Desktop Applications (page 160.

I hope to be OK this time. Am I ?

Your question seems more legit now that I searched in the documentation (remember I know what to do *) and I had a bit of hard times.

  • Its a long time sine I added this feature to a project, so my memory is not what it was then. Also, with the new IDE, things appears a bit differently (Click in the “Choose…” button is not obvious at first).

To create file associations on the Mac, using FileTypes is (most times) all you need.

On Linux, I don’t know any way at all. It may be desktop app specific, even. I looked for a solution 2 or 3 years ago and was told that there isn’t one.

On Windows, you’ll have to modify the registry. Which is quite a pain as well because you need to deal with multiple paths that are different between the Windows versions. I recommend that you use an installer on Windows, which should not only allow the user to choose if he really wants the associations created but should also remove them when you uninstall the program again (with the included uninstaller, of course).

For OS X, you can refer to User Guide Book 4: Development, Chapter 2: Cross-Platform Development, Section 3: OS X Features, 3.1: Uniform Type Identifiers (UTI).

On Windows, you would typically use the tool you use to create your installer to set up file associations.

I’m not sure about Linux.

Ok, I’ve got it working now.

Thanks :slight_smile:

Ive spent weeks trying to get a reliable ‘associate file extension’ to work on Windows.
I had it working fine on Windows 9x but these days, it seems that WIndows doesnt like you to claim exclusive ownership of a file type.
The best I can seem to achieve is ‘you may want to consider me if…’
Which would be fine if it wasnt for the fact that my file extension is pretty unique to my app.
I have to compete with older versions of my app… :wink:

So if anyone has code which reliably sets the ‘default app’ as opposed to just ‘you may want to consider me if…’

Jeff, give this a try, that’s the code I use in Arbed.

http://files.tempel.org/RB/Windows%20Registry%20Extensions.rbp.zip

But I must admit that I do not even understand it too well any more. Should have doc’d it better.

Also, there’s no code yet to remove the associations again. If you manage to add that, please let me know, I should add that to Arbed, too.

Thats certainly easy to add, Thomas.
Thank you.
I’ll let you know how I get on when I ship the next Windows build.

Andre,

can you create a simple document to explain how it have to be done ?

If you do not have time to do the whole, you can do less, pass me the data and I will add screen shots, page layout, etc. and make it available for (bug, feature, typos removals, etc.) reports, then for reference for all of the Xojo users.

drop me a mail there: emile.schwarz@yahoo.com

[quote=40931:@Emile Schwarz]Andre,

can you create a simple document to explain how it have to be done ?

If you do not have time to do the whole, you can do less, pass me the data and I will add screen shots, page layout, etc. and make it available for (bug, feature, typos removals, etc.) reports, then for reference for all of the Xojo users.

drop me a mail there: emile.schwarz@yahoo.com[/quote]

I just got it working on the MAC, but haven’t tried Windows yet. On Mac it is an easy job as explained in the books, but I couldn’t get it to work in the first place, because I also used UTI. After leaving the UTI field blanc, it work liked a charm.