Using Windows Explorer to load program

wapo54001

Senior Member
I am accustomed to using Windows Explorer to find and load a data file into the appropriate executable program for editing etc by simply double-clicking the data file.

In the case of other programs, if the executable is already running and I double-click a data file, the data file is loaded into the program and is displayed on the screen.

In the case of the Picaxe Program Editor, however, if the Editor is already running when I double-click a data file, I get a loud rude noise from my computer speakers and an error message saying

"Duplicate ...
Programming Editor is already running! Use File>Opne (sic) menu to open the file"

It's annoying and inconvenient and not Windows standard. If possible, please program the editor to accept the Windows Explorer method of selecting a data file to open in the editor even when the editor is already running.

Thank you.
 

Technical

Technical Support
Staff member
This is a Windows restriction. As Programming Editor uses the serial COM ports for downloading, if more than one instance opened there would be potential serial port conflicts, as only one application can use the port at a time. That is why the multiple files need to be opened within the same instance, as opposed to, for instance, Word where you can have multiple instances running.

The error message comes from the second instance, not the first. The first instance does not actually know you have tried to open another file via this method.
 

wapo54001

Senior Member
Technical,

Thank you for your prompt response. The Com port issue had not occurred to me.

However, as I think about this further, I am led to ask why must there be a second instance of the executable running? Cannot the executable open the data file as a second window as you would do if you did it manually?

Alternatively, should not the software ask whether to close the currently open data file and open the new data file (after asking whether to save the old one, of course).

I suppose there must be some reason why none of this is feasible. Without a knowledge of Windows, it's impossible to tell whether something is doable or quite impossible so you get questions like this.

Thanks.
 

wapo54001

Senior Member
Thanks, Hippy,

My desire is somewhat different -- usually I don't need two data files open simultaneously, I just want the convenience of having them pop up in Programming Editor when I double click them in Windows Explorer, even if PE is already open.

On the occasions when I do want two open at once, I still would wish PE to open a new data file window when I double click a data file.

I guess you have to know the technical details to know why it won't work. Not knowing them, it would seem to me that if you can open two or more data files in PE via the PE menu (Start>Open), then you should be able to do the same thing via the Windows Explorer method, but apparently not.
 

hippy

Ex-Staff (retired)
It's quite complicated but not impossible. If you open a file within PE obviously PE itself knows there's a new file being opened, when you click on a another file outside of PE Windows has to tell the associated app something's happened. That can be done by launching a new hidden instance which communicates with the first instance, and there may be other clever Windows trickery to utilise, but it's not as simple as it could be. I am intrigued with the concept though so I may give it a try.

I hadn't quite appreciated exactly what you were hoping to have happen. What you suggest makes sense for an application which can only have one instance open.
 

Technical

Technical Support
Staff member
Technical,
However, as I think about this further, I am led to ask why must there be a second instance of the executable running? Cannot the executable open the data file as a second window as you would do if you did it manually?
You need to understand the difference between 'MDI' and 'instances' of a program.

Prog Editor ia a Multi Document Interface application, which means it can have more than one program at a time, but this is still just one 'instance' of the application.

When you double click in the file manager the Windows operating system just tries to start up another instance of the program, it does not care or check that one instance is already open. We specify prevent this due to the serial port conflict issues that could then arise.
 

hippy

Ex-Staff (retired)
This is a 'fake Programming Editor', an Explorer click on any file associated with MultiDoc.exe will open a new window within the single instance IDE. I think that's what wapo54001 was getting at.

It's quite a neat idea, and I think it would work well for the Programming Editor, and very few changes needed to make it work. There are a few programs I could do with adding that to of my own :)

http://homepage.ntlworld.com/the.happy.hippy/picaxe/multidoc.zip
 

wapo54001

Senior Member
Hippy,

What is a "fake programming editor" -- sounds like a program you wrote to test the concept? Are you a Picaxe guru AND a Windows programmer??

Anyway, does the content of the ZIP file solve my problem? What should I do with it? I've downloaded it, awaiting instructions, captain!
 

hippy

Ex-Staff (retired)
It's just proof of concept code to show how it could work; associate some file extension with it and click away. No it won't solve your problem, only updating the Programming Editor itself would do that.

Although ... one could associate .bas files with another app which could launch the Programming Editor if not already open and then use SendKeys to get it to load other files as launched but that's not very elegant. I'm not planning on writing that code.
 

wapo54001

Senior Member
Well, I'd dearly love the solution to appear in Programming Editor. I keep forgetting that Program Editor is already open and get this nasty noise and a window telling me to open files through the PE executable.

Perhaps I'm the only one who keeps running into this issue simply because of the way that I'm accustomed to working. PE is often buried under other windows when I want to open a file, so it's easy to forget that it's already open.
 

Tom2000

Senior Member
When you send a file to an open app via an Explorer double-click, I believe that Explorer coordinates the app's opening the target file by means of a DDE exchange. (I know that's how Media Player adds .MP3 files to its playlist while it's already playing something else.)

I haven't chased down the specific DDE syntax, though.

So, I'm guessing that adding the correct DDE handler would allow Program Editor to open the new file in response to an Explorer double-click.

Tom
 

hippy

Ex-Staff (retired)
Not sure how to get Explorer / File Manager to send DDE itself ( I guess this is part of the Shell operations in the Registry ). I took the short and sweet solution of letting the click launch the application which is its defaut behaviour and then the app itself determines if it's a second instance and if so sends the new file details via DDE and closes.

I've also got round to adding drag-and-drop for files plus being able to dynamically switch between Single Document Interface ( single file at a time, like NotePad ) and Multi-Document Interface, so thanks for the inspiration.
 

Tom2000

Senior Member
Not sure how to get Explorer / File Manager to send DDE itself ( I guess this is part of the Shell operations in the Registry ). I took the short and sweet solution of letting the click launch the application which is its defaut behaviour and then the app itself determines if it's a second instance and if so sends the new file details via DDE and closes.

I've also got round to adding drag-and-drop for files plus being able to dynamically switch between Single Document Interface ( single file at a time, like NotePad ) and Multi-Document Interface, so thanks for the inspiration.
Hippy,

I add "multi-launch" prevention to all my Win programs by means of a Win MUTEX message. I don't want to post the code here, but PM me if you're interested. I'll send along an annotated example.

Years ago, I linked two programs using DDE. One controlled the other, and received status and state information from the controlled program. It's not exactly what's needed here -- the specific syntax of the Explorer/Application DDE exchange -- but it's at least an example of DDE "transceive" operation. Again, if you're interested, PM me and I'll ship you some examples.

Best,

Tom


Edited to add:

It occurred to me that Program Editor might already have the framework on board to implement Explorer-initiated .bas file openings, so I just ran a little test.

I tried an Explorer launch of a .bas file to an open instance of Program Editor. Got an error message. So far, so good. It's detecting and processing the opening attempt.

Then, with no document open in Program Editor, I tried to open a second instance of the program by clicking my desktop icon. Got the same error message.

So it looks like Program Editor just implements multi-launch blocking, as do my programs (although mine do it silently.) It doesn't look like there's any framework in there to capture the path of the file the user is trying to launch. Doggone it!
 
Last edited:
Top