File Associations Part 2

T

Terry Olsen

I have a code-editor application. I have associated a filetype with the
application. Double-clicking on a file will open the code-editor and
open the file. Works great.

My application is an MDI application. Each file is opened in a new child
window. However, if the application is already running, it does
according to the initial CommandLineArgs value. If there were no initial
command line args, then double-clicking on a new file does nothing. If
there was an initial CommandLineArg value, it re-opens the initial file
contained therin.

So, if the app is already running, and I double-click a file to open it,
how do I get my app to respond and open the clicked-on file?
 
T

Terry Olsen

Found my own answer! Needed to use the ApplicationEvents.vb to handle
the StartupNextInstanceEvent. But trying to elegantly run the document
load code in the main form is not easy. I came up with this
not-so-elegant way of doing it:

In the ApplicationEvents.vb under the StartupNextInstanceEvent handler,
I have this:

modGlobals.docToOpen=e.CommandLine(0).ToString

Then in the MainForm under the Activated Event Handler, I have this:

If modGlobals.docToOpen<>"" Then
ShowNewChildForm(docToOpen)
docToOpen=""
End If

Is this a good way to do it? Or is there a better way?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top