Double click then load my prog

Blitz3D Forums/Blitz3D Beginners Area/Double click then load my prog

DjBigWorm(Posted 2003) [#1]
Hi,

You know in windows, when you double click on a pic, music file, or txt. It then runs the appropriate program and the file you clicked on appears in the prog Ready to edit or view?
How is that done in Blitz? Or can it be done right now?

Thanks in Advance


soja(Posted 2003) [#2]
For .bb files, I assume. You can do it from the File Types tab in Windows Explorer's Tools->Folder Options menu.


Perturbatio(Posted 2003) [#3]
If you want to associate a certain file type with your program, you need to modify the registry (either programatically or manually).

The filetypes are defined in hkey_classes_root.


DjBigWorm(Posted 2003) [#4]
no, I don't want to do .bb files
I have my own file type. I have an editor for it.
I have to run the editor then, load the file.
If I double click on "my file". XP then tells me
that it isn't associated with any program. I chooose "my program". It then goes to load and closes out. I want "my program"to stay open with "my file" ready to edit.


soja(Posted 2003) [#5]
I chooose "my program". It then goes to load and closes out. I want "my program"to stay open with "my file" ready to edit.


This doesn't sound like a file association problem... it sounds like a problem with your editor. (An editor that you wrote, right?) If I'm off base here, please be very detailed and thorough in your follow-up.

PS: You can make it so that Windows will not ask you what program to open your file with each time by clicking the "Always use the selected program to open this kind of file" checkbox on the "Open With" dialog (where you choose "your program").


DjBigWorm(Posted 2003) [#6]
@soja,
I will be as detailed as I can:) Yes it is an editor that I have made. It is not a file association issue. The file that is saved on the harddrive is of my own creation. I can load my file from within my program. I want to make my editor to where you double click on the save file. My main program goes to load, then right before it displays anything it closes:( I want it to behave Just like when you double click on a .bmp file and the bmp editor opens with the bmp in the editing window.


Perturbatio(Posted 2003) [#7]
that *is* a file association issue. i.e. you want to associate your custom filetype with your application.


DjBigWorm(Posted 2003) [#8]
@perturatio

The file is associated to my program after the first time I tried to double click on it. It runs my program after I double click on the file. Then loads, and..(drum roll) Nothing (ta da..:( Just goes to full screen then closes right away.


Perturbatio(Posted 2003) [#9]
Ah right, I understand now, you need to look at the command line parameters for your executable to see if a file has been passed to it.
assuming no other command line options are going to be used, you could do something like:

file$=CommandLine$() 
;REMOVE THE QUOTES
file$= Left(file$,Len(file$)-1)
file$ = Right(file$, Len(file$)-1)

If FileType(file$) = 1 then LoadFile(file$) ;file exists



DjBigWorm(Posted 2003) [#10]
@perturbatio

Yes, that seems to be something with my prob.
I don't understand why it just closes after it is ran, and the commandline$ is passed to it?


Perturbatio(Posted 2003) [#11]
you might need to post some code for this.
what is the content of CommandLine$() when you do this?
*EDIT* i.e. put a DebugLog CommandLine$() line in your code and see what it reports.


DjBigWorm(Posted 2003) [#12]
ok, the commanline$() points to the file I am using.
*edit debuglog="C:\BlitzProgramming\Worms_Games\castlebania\Sprites\story.ibf"
I have tracked it to this command


temp_image(0)=LoadImage("images/def2.bmp")<----crashes
;after loadimage command??
;yes the image exsists

I am using version of blitz+ 1.37


FlameDuck(Posted 2003) [#13]
temp_image(0)=LoadImage("images/def2.bmp")<----crashes
This is because your application is looking for the image in the wrong place. Specificly it's looking for it in the directory (folder) where your map is, because that's the "current folder".

[Edit]You can use SystemProperty("appdir") to get the proper location.
myImage = LoadImage(SystemProperty("appdir")+filename$)



Perturbatio(Posted 2003) [#14]
Assuming the media exists and the path is correct, I'm not sure how much more I can tell you with just one line of code.


DjBigWorm(Posted 2003) [#15]
@FlameDuck
Thank You Worked Right Away!!!

@others
Thanks to everyone who replied
You Rock!!

Peace