Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wm5 .net cf 3.5 launch args on restore.

Status
Not open for further replies.

acecase

Programmer
Oct 29, 2004
11
US
I'm sorry for the pitiful subject for this thread, but I can't think of a better way to word it.

What I have is a simple text editor for wm5 (BareAce). I have written it to accept arguments so that I can open txt files using resco file explorer's "open with" option, which simply launches the program with a file path as an argument. (open with -> BareAce)

The problem is that if I have the program running and try to open a file with it, it will bring the program to the front and since it isn't actually being launched, the Main() function isn't getting fired, and therefore it isn't passing the args to Form1 etc etc. My whole execution path is dead after the first launch.

With this behavior, I have no way of getting a file name/path to use in order to open the desired file.

A quick fix would be to make sure the program actually closes and doesn't minimize but I don't want it to work like that.

I have all the code working so that when I open a file and I already have an unsaved file open in the program, it will ask me if I would like to save or not, or cancel (the standard way to handle it) but again it is broken if I can't get the file name of the new file.

I am the worst at explaining things so, please let me know if I haven't made clear my predicament and I will try to better help you guys to help me :).

Thanks,
acecase
 
So you have an instance of the application open already and when you open a second instance, you instead want to pass the arguments to the first instance?

 
Again, I apologize for being so unclear.

When the program (BareAce) is already running and I use "open with" to open a txt file with BareAce, I want to be able to accept the argument that "open with" passes. The only argument that open with should pass is the filename.

I have added (String[] args) to the Main constructor and when the program is started and isn't already running this works. However, when the program is already running it is only raised/restored, therefore the Main() function isn't called as it is when it is first launched.

My problem is that I have no idea how wm5 handles the detection of a program already running and restores instead of launching a new instance. Moreover, what wm5 does with any arguments used for the initial call in such a case.


I'm am one of the worst for long post, but I am even worse at explaining things :) so maybe this will help....

wm5 file browser doesn't have an option to open a file with a specific program (open with). It relies fully on association. However, Resco File Explorer does have the option. The way that resco handles it is the standard, launch application with fileName as an argument.

My program accepts one argument so that I can use that functionality to open files with my program from resco. This works fine as long as my program isn't already running. However, if my program is already running when resco tries to launch it with the filename as an argument, wm5 sees that I am trying to launch a program that is already running and instead of launching it, wm5 restores it. Since it is being restored my program never has a chance to use the filename argument that resco is sending and therefore it opens with the file that is already loaded instead of the one that I am trying to load with "open with" from resco.

What I am trying to figure out is a way for my program to get the filename argument from resco even when it is being restored instead of launched.

Thanks for your response and any help in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top