(Fwd) Single-instance support on Windows
- From: christian ridderstrom gmail com
- To: Dia-list gnome org
- Subject: (Fwd) Single-instance support on Windows
- Date: Sun, 17 Dec 2006 21:53:01 +0100
From another list (about) LyX, I saw a description on how it might be
possible to add support for a single instance. Maybe it's useful for Dia?
Anyway, I've just copied below just in case.
/Christian
----------------------------------------------------------------
Here is a detailed description of how single-instance support can be
implemented on Windows. This feature will allow users to open LyX files
using the Windows explorer in the current LyX process, so copy & paste
works and data is shared between all windows. Like on Mac OS X, this is
the standard behavior for Windows applications.
* LyX startup
A mutex should be created using CreateMutex and a unique identifier. If
this succeeds, the usual startup can continue.
If the return value is ERROR_ALREADY_EXISTS, the current user is already
running LyX. In this case a new window should be created in the existing
process. Any files specified on the command line should be opened in this
window.
* Communicating to existing LyX process
After it has determined that LyX is already running, the HWND of one of
the current windows needs to be found. This can be done by creating a
unique window message with RegisterWindowMessage and the unique
identifier. This message should be sent to all open windows using
EnumWindows. In GuiApplication.C, a WinEventHandler function can capture
this message and send a return value, so the calling process knows that
LyX is found.
To open files in this process a WM_COPYDATA message with a COPYDATASTRUCT
can be used to send the filename (probably in Unicode?), which will also
be handled in the WinEventHandler.
* Command line option
A command line option can be added to disable this behavior (that is,
start a new instance). I think this is better than a preference because it
allows one to create a shortcut to start a new instance.
Regards,
Joost
--
Christian Ridderström, +46-8-768 39 44 http://www.md.kth.se/~chr
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]