// Retrieve your application's window Id
WId mwWinId = winId();
// Restore your application, should it be minimized
if (IsIconic(mwWinId))
SendMessage(mwWinId, WM_SYSCOMMAND, SC_RESTORE, 0);
// Bring your application to the foreground
DWORD foregroundThreadPId = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
DWORD mwThreadPId = GetWindowThreadProcessId(mwWinId, NULL);
if (foregroundThreadPId != mwThreadPId) {
// Your application's thread process Id is not that of the foreground window, so
// attach the foreground thread to your application's, set your application to the
// foreground, and detach the foreground thread from your application's
AttachThreadInput(foregroundThreadPId, mwThreadPId, true);
SetForegroundWindow(mwWinId);
AttachThreadInput(foregroundThreadPId, mwThreadPId, false);
} else {
// Your application's thread process Id is that of the foreground window, so
// just set your application to the foreground
SetForegroundWindow(mwWinId);
}
// Retrieve your application's window Id
WId mwWinId = winId();
// Restore your application, should it be minimized
if (IsIconic(mwWinId))
SendMessage(mwWinId, WM_SYSCOMMAND, SC_RESTORE, 0);
// Bring your application to the foreground
DWORD foregroundThreadPId = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
DWORD mwThreadPId = GetWindowThreadProcessId(mwWinId, NULL);
if (foregroundThreadPId != mwThreadPId) {
// Your application's thread process Id is not that of the foreground window, so
// attach the foreground thread to your application's, set your application to the
// foreground, and detach the foreground thread from your application's
AttachThreadInput(foregroundThreadPId, mwThreadPId, true);
SetForegroundWindow(mwWinId);
AttachThreadInput(foregroundThreadPId, mwThreadPId, false);
} else {
// Your application's thread process Id is that of the foreground window, so
// just set your application to the foreground
SetForegroundWindow(mwWinId);
}
To copy to clipboard, switch view to plain text mode
Bookmarks