Click and Open Files in Editor

BlitzMax Forums/BlitzMax Programming/Click and Open Files in Editor

Zenn Lee(Posted 2007) [#1]
Hi, I've been working on a little editor and is their a way that if you clicked on my editor's file type, .sq, in explorer, for example, could I have it open in my editor. Much like when you click on a .jpg file and it opens in Photoshop.

Oh yes, one more thing, how would you set all of one file type to have a file type image.

Thanks


Gabriel(Posted 2007) [#2]
See if there's anything here that helps.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/fileassociations/fa_intro.asp


Zenn Lee(Posted 2007) [#3]
I can make it so the my editor will open when you click on a .sq file but I can't get it to open the file.


Gabriel(Posted 2007) [#4]
That should be the easy bit. Parse the commandline and the filename you want should be there.

Of course if your App is already running, then you have to do fancy stuff like creating a Mutual Exclusion Object ( Mutex )to stop your program running multiple times ( and presumably to parse the commandline which would have been sent to the program if you had let it open so that you can open the file in the existing instance of your application.


Zenn Lee(Posted 2007) [#5]
Um, uh, what? Would the file name be in memory once I try to open my file type, and the editor opens. Could I use a pointer to accesses it. Could you please restate what you said. Sorry, I'm just kind of confused:)


Gabriel(Posted 2007) [#6]
I don't know exactly how it works, but I assume the stuff I gave you earlier on file associations ends up with passing the name of the file as a command line argument to your program.

So try this :


For Local a:String = EachIn AppArgs
  Print a
Next


Once you've worked out which one is the filename ( probably 0 ) you can grab it directly with AppArgs[Index] and open that file.


grable(Posted 2007) [#7]
Once you've worked out which one is the filename ( probably 0 ) you can grab it directly with AppArgs[Index] and open that file.


Actually, index 0 is allways the path+filename of the executable ;)


Gabriel(Posted 2007) [#8]
Oh ok. In the docs I read :

[/quote]However, the format of the name may change depending on how the application was launched.[/quote]

And I thought "how the application was launched" might be referring to just this sort of situation.