1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

Windows: Don't use the foreground setting code if the window is already foreground

This commit is contained in:
Mounir IDRASSI
2016-03-23 22:50:28 +01:00
parent ece26c7481
commit 1e204da223

View File

@@ -6954,22 +6954,25 @@ void BringToForeground(HWND hWnd)
DWORD dwThisTID = ::GetCurrentThreadId(), DWORD dwThisTID = ::GetCurrentThreadId(),
dwCurrTID = ::GetWindowThreadProcessId(hCurrWnd,0); dwCurrTID = ::GetWindowThreadProcessId(hCurrWnd,0);
if(dwThisTID != dwCurrTID) if (hCurrWnd != hWnd)
{ {
::AttachThreadInput(dwThisTID, dwCurrTID, TRUE); if(dwThisTID != dwCurrTID)
{
::SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT,0,&lockTimeOut,0); ::AttachThreadInput(dwThisTID, dwCurrTID, TRUE);
::SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,0,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
::SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT,0,&lockTimeOut,0);
::AllowSetForegroundWindow(ASFW_ANY); ::SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,0,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
}
::AllowSetForegroundWindow(ASFW_ANY);
::SetForegroundWindow(hWnd); }
if(dwThisTID != dwCurrTID) ::SetForegroundWindow(hWnd);
{
::SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,(PVOID)lockTimeOut,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE); if(dwThisTID != dwCurrTID)
::AttachThreadInput(dwThisTID, dwCurrTID, FALSE); {
::SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,(PVOID)lockTimeOut,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
::AttachThreadInput(dwThisTID, dwCurrTID, FALSE);
}
} }
#ifdef TCMOUNT #ifdef TCMOUNT