VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Dlgcode.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-03-23 22:50:28 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-03-24 01:36:08 +0100
commit1e204da223991549a9204cb7d61da7042c2bbb70 (patch)
treed6605dd5ab47c2728010b2a450949a96634a2d20 /src/Common/Dlgcode.c
parentece26c74815c431b0c489a24292e7834181463a7 (diff)
downloadVeraCrypt-1e204da223991549a9204cb7d61da7042c2bbb70.tar.gz
VeraCrypt-1e204da223991549a9204cb7d61da7042c2bbb70.zip
Windows: Don't use the foreground setting code if the window is already foreground
Diffstat (limited to 'src/Common/Dlgcode.c')
-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 da37795d..24f93559 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