File association with a program
File association with a program
Sorry if the title to the thread is not correct, did not know what to call it, lol.
Anyway want I want to be able to achieve is this . . .
I have created a program that will print a fax header ready to be faxed on a fax machine, I have managed to get the program to save the faxes which is basically a text file containing things like the recipient, date, message, etc.
I have associated my program files (.fxm) with the program and when you click on one of these files it opens my program which is kinda right but when the program opens all the fields are blank, I want to click a file and my program to read in the values and put them in the appropriate boxes, similar to clicking on a Word document and it opening Word with the letter on your screen.
Can anyone give me an example, please remember I'm a newbie.
Kind regards
Andy ( aka Large )
Anyway want I want to be able to achieve is this . . .
I have created a program that will print a fax header ready to be faxed on a fax machine, I have managed to get the program to save the faxes which is basically a text file containing things like the recipient, date, message, etc.
I have associated my program files (.fxm) with the program and when you click on one of these files it opens my program which is kinda right but when the program opens all the fields are blank, I want to click a file and my program to read in the values and put them in the appropriate boxes, similar to clicking on a Word document and it opening Word with the letter on your screen.
Can anyone give me an example, please remember I'm a newbie.
Kind regards
Andy ( aka Large )
This could be useful Pupil . . .
But I'm clicking on a file to open my program I need a way for my program to know what the path and filename I have just clicked on then I can set the gadgets with values.
basically . . .
if user clicked file
get filename and path
read file and set gadget values
end if
Kind regards
Andy ( aka Large )
But I'm clicking on a file to open my program I need a way for my program to know what the path and filename I have just clicked on then I can set the gadgets with values.
basically . . .
if user clicked file
get filename and path
read file and set gadget values
end if
Kind regards
Andy ( aka Large )
When someone d-clicks on your file the file name will be sent as a parameter to the recieving program, as if you are starting your program from the cmd line.
like this:
FaxHeaderPrinter.exe TestFax.fxm
so in your FaxHeaderPrinter.exe program check for the name of 'TestFax.fxm' file using ProgramParameter() then open this file read the contents and do with them what you will. simple
like this:
FaxHeaderPrinter.exe TestFax.fxm
so in your FaxHeaderPrinter.exe program check for the name of 'TestFax.fxm' file using ProgramParameter() then open this file read the contents and do with them what you will. simple

Well I'm afraid I'm not getting on to well . . .
I'm using this line at the beginning of my program.
and then to see what parameter$ holds I'm testing it with.
that way I can see the filename but when I try this gadget 1 is empty.
You guys got any idea's how I can click on a file which will open the associated program and the program to know the path and filename that launched it.
Any help greatly appreciated.
Kind Regards
Andy ( aka Large )
I'm using this line at the beginning of my program.
Code: Select all
parameter$ = ProgramParameter()
Code: Select all
SetGadgetText (1,parameter$)
You guys got any idea's how I can click on a file which will open the associated program and the program to know the path and filename that launched it.
Any help greatly appreciated.
Kind Regards
Andy ( aka Large )
-
- Enthusiast
- Posts: 781
- Joined: Fri Apr 25, 2003 6:51 pm
- Location: NC, USA
- Contact:
Andy, I think Kale's advice puts you on the right path. But, your file
association must tell the OS what to do with the file. So your "open"
command must pass the filename.
I don't have my notes with me, but as I recall it is something like this:
in action you need
\PureBasic\PBProgram.exe "%1"
or
\PureBasic\PBProgram.exe "%file"
Sorry I can't be more exact. I have simply forgotten how these
parameters are defined in the association. Hope this will get you a
starting place to figure it out.
Terry
association must tell the OS what to do with the file. So your "open"
command must pass the filename.
I don't have my notes with me, but as I recall it is something like this:
in action you need
\PureBasic\PBProgram.exe "%1"
or
\PureBasic\PBProgram.exe "%file"
Sorry I can't be more exact. I have simply forgotten how these
parameters are defined in the association. Hope this will get you a
starting place to figure it out.
Terry
I have set up the file association so that clicking on the file and the program opens, the file assocation has by default added "%1" for the file path part.
I'm using :
but the gadget is empty.
Any idea's anyone ???
Kind regards
Andy ( aka Large )
I'm using :
Code: Select all
file$=programparameter()
setgadgettext(2,file$)
Any idea's anyone ???
Kind regards
Andy ( aka Large )
Compile this code and associate a file to the .exe, then double click the file!
Code: Select all
parameter.s = ProgramParameter()
OpenWindow(1, 0, 0, 600, 40, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, parameter)
CreateGadgetList(WindowID(1))
StringGadget(1, 10, 10, 580, 20, "")
SetGadgetText(1, parameter)
Repeat
EventID.l = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
Large,
Look at this posting:
viewtopic.php?t=6365
it is just a snippet of code to help you get all of the
parameters passed to a program.
Hope this helps.
HarryO
Look at this posting:
viewtopic.php?t=6365
it is just a snippet of code to help you get all of the
parameters passed to a program.
Hope this helps.
HarryO