From dd63985cfdc47055027c60f775fcd1d760166a25 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 9 Jun 2022 21:17:34 +0000 Subject: Deploy to GitHub pages --- md_Windows.html | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 md_Windows.html (limited to 'md_Windows.html') diff --git a/md_Windows.html b/md_Windows.html new file mode 100644 index 0000000..d8e8a6b --- /dev/null +++ b/md_Windows.html @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + +SingleApplication: Windows Specifics + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
SingleApplication +
+
Replacement for QtSingleApplication
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
Windows Specifics
+
+
+

+Setting the foreground window

+

In the instanceStarted() example in the README we demonstrated how an application can bring it's primary instance window whenever a second copy of the application is started.

+

On Windows the ability to bring the application windows to the foreground is restricted, see [AllowSetForegroundWindow()][https://msdn.microsoft.com/en-us/library/windows/desktop/ms632668.aspx] for more details.

+

The background process (the primary instance) can bring its windows to the foreground if it is allowed by the current foreground process (the secondary instance). To bypass this SingleApplication must be initialized with the allowSecondary parameter set to true and the options parameter must include Mode::SecondaryNotification, See SingleApplication::Mode for more details.

+

Here is an example:

+
if( app.isSecondary() ) {
+
// This API requires LIBS += User32.lib to be added to the project
+
AllowSetForegroundWindow( DWORD( app.primaryPid() ) );
+
}
+
+
if( app.isPrimary() ) {
+
QObject::connect(
+
&app,
+ +
this,
+
&App::instanceStarted
+
);
+
}
+
void instanceStarted()
Triggered whenever a new instance had been started, except for secondary instances if the Mode::Secon...
+
void App::instanceStarted() {
+
QApplication::setActiveWindow( [window/widget to set to the foreground] );
+
}
+
+
+
+ + + + -- cgit v1.2.1