[plt-scheme] How to open a source file in an already running DrScheme?

From: Gordon Weakliem (gweakliem at oddpost.com)
Date: Tue Mar 30 17:23:40 EST 2004

You're correct, it's up to the application on Win32 to figure out that it should reuse an existing application instance in this case.  It's not too bad to solve.  You have to achieve 2 things: 
1) On startup, detect that there's another instance running.  You'd normally do this before registering window classes, before anything else, really.  The article at [1] outlines the approach, essentially, create a named mutex with a name that's unique to PLT Scheme, and probably the current user's desktop; his solution is a GUID + the current user's desktop name. 
2) If there is another instance running, send that instance an Open File command and terminate.  Open File probably boils down to finding the top level window for the original instance and then posting a message with whatever arguments would cause DrScheme to open a specific file. 
I poked around in the source for a while, but I'm having trouble figuring out step 2, in particular, where the menu commands would be defined.  It's also possible that DrScheme doesn't have a message saying "Open this specific file", as opposed to "Open the Open File dialog box", I'm not sure. 
[1] http://www.codeproject.com/cpp/avoidmultinstance.asp  
Gordon Weakliem 
-----Original Message from ifconfig <nslookupifconfig at hotmail.com>----- 
For list-related administrative tasks: 

I think this is part of the program; when you open Office documents, for 
example, it recognizes that a process is already running. I'm only guessing, 
but that's probably what it does on the Mac. I know many programs that do 
that on Windows, so I don't think it would be too hard to implement - and it 
is quite an annoying wait. I never open files by double-clicking them 
because of that - is there anything you could do about it, maybe for v300? 


> -----Original Message----- 
> From: plt-scheme-admin at list.cs.brown.edu [mailto:plt-scheme- 
> admin at list.cs.brown.edu] On Behalf Of Jens Axel S?gaard 
> Sent: Monday, March 29, 2004 4:29 PM 
> Cc: plt-scheme at list.cs.brown.edu 
> Subject: Re: [plt-scheme] How to open a source file in an already running 
> DrScheme? 
>   For list-related administrative tasks: 
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme 
> Robby Findler wrote: 
> > On the mac, you can use the command "open" from the shell (or scripts) 
> > to open a new file. I'm not sure if something like that exists under 
> > windows (you are using windows, right?) 
> Yes WinXP - mostly. 
> -- 
> Jens Axel Søgaard

Posted on the users mailing list.