What is it called and how to implement this behavior?

216 views Asked by At

I am practicing with wxwidgets minimal sample and I wanted to implement this behavior, I do not know what is it called. The behavior is this; (using audacity since it uses wxwidgets too) when you open the program using a direct access it stars normally but if you click again the direct access, it sends you to the current instance you already opened, also in windows 10 if you have for example 4 desktops and you open the program in desktop 4, and then you go to desktop 1 and click the direct access, it sends you to the program running in desktop 4.

How can I implement this in wxwidgets? than you in advance.

1

There are 1 answers

0
VZ. On BEST ANSWER

What you're looking for is typically (at least under Windows) called "single instance applications" and to achieve this you need to have some kind of IPC between different instances (i.e. copies) of your application.

Generally speaking, on startup a single instance application would try to open an IPC channel to another version of itself and, if it succeeds, send its own command line arguments, if any, to the existing instance and exit the current one. Of course, if it fails, the application would continue running as normal under the assumption that there is no other instance.

With wxWidgets, you can use wxSingleInstanceChecker class to just perform the check, but this is usually not enough, so you would also use wxServer and wxClient objects to actually transmit information between instances. You can read more about them in the IPC overview in the manual.