VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-03-23 21:50:28 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-03-24 00:36:08 (GMT)
commit1e204da223991549a9204cb7d61da7042c2bbb70 (patch)
treed6605dd5ab47c2728010b2a450949a96634a2d20
parentece26c74815c431b0c489a24292e7834181463a7 (diff)
downloadVeraCrypt-1e204da223991549a9204cb7d61da7042c2bbb70.zip
VeraCrypt-1e204da223991549a9204cb7d61da7042c2bbb70.tar.gz
Windows: Don't use the foreground setting code if the window is already foreground
-rw-r--r--src/Common/Dlgcode.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index da37795..24f9355 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -6954,22 +6954,25 @@ void BringToForeground(HWND hWnd)
DWORD dwThisTID = ::GetCurrentThreadId(),
dwCurrTID = ::GetWindowThreadProcessId(hCurrWnd,0);
- if(dwThisTID != dwCurrTID)
+ if (hCurrWnd != hWnd)
{
- ::AttachThreadInput(dwThisTID, dwCurrTID, TRUE);
-
- ::SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT,0,&lockTimeOut,0);
- ::SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,0,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
-
- ::AllowSetForegroundWindow(ASFW_ANY);
- }
-
- ::SetForegroundWindow(hWnd);
-
- if(dwThisTID != dwCurrTID)
- {
- ::SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,(PVOID)lockTimeOut,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
- ::AttachThreadInput(dwThisTID, dwCurrTID, FALSE);
+ if(dwThisTID != dwCurrTID)
+ {
+ ::AttachThreadInput(dwThisTID, dwCurrTID, TRUE);
+
+ ::SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT,0,&lockTimeOut,0);
+ ::SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,0,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
+
+ ::AllowSetForegroundWindow(ASFW_ANY);
+ }
+
+ ::SetForegroundWindow(hWnd);
+
+ if(dwThisTID != dwCurrTID)
+ {
+ ::SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,(PVOID)lockTimeOut,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
+ ::AttachThreadInput(dwThisTID, dwCurrTID, FALSE);
+ }
}
#ifdef TCMOUNT