Skip to content

Commit 3f2da6c

Browse files
committed
Generalize focus fix to all dialogs
1 parent aa38063 commit 3f2da6c

5 files changed

Lines changed: 23 additions & 21 deletions

File tree

src/OpenWithEx.vcxproj.user

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
4-
<LocalDebuggerCommandArguments>"C:\Users\Aubrey\lol.somefake"</LocalDebuggerCommandArguments>
4+
<LocalDebuggerCommandArguments>"C:\shit.fuckassbitch"</LocalDebuggerCommandArguments>
55
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
66
</PropertyGroup>
77
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
8-
<LocalDebuggerCommandArguments>"C:\Users\Aubrey\lol.somefake"</LocalDebuggerCommandArguments>
8+
<LocalDebuggerCommandArguments>"C:\shit.fuckassbitch"</LocalDebuggerCommandArguments>
99
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
1010
</PropertyGroup>
1111
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
12-
<LocalDebuggerCommandArguments>"D:\0e\Pictures\Profile Pictures\zhen.jpg"</LocalDebuggerCommandArguments>
12+
<LocalDebuggerCommandArguments>"C:\shit.fuckassbitch"</LocalDebuggerCommandArguments>
1313
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
1414
</PropertyGroup>
1515
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
16-
<LocalDebuggerCommandArguments>"D:\0e\Pictures\Profile Pictures\zhen.jpg"</LocalDebuggerCommandArguments>
16+
<LocalDebuggerCommandArguments>"C:\shit.fuckassbitch"</LocalDebuggerCommandArguments>
1717
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
1818
</PropertyGroup>
1919
<PropertyGroup>

src/baseopenasdlg.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -165,22 +165,6 @@ INT_PTR CALLBACK CBaseOpenAsDlg::v_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam,
165165

166166
return TRUE;
167167
}
168-
// For some reason, initializing through the server doesn't activate the window.
169-
// Let's activate it manually when it's shown.
170-
case WM_WINDOWPOSCHANGED:
171-
if (((LPWINDOWPOS)lParam)->flags & SWP_SHOWWINDOW && !m_fShown)
172-
{
173-
m_fShown = true;
174-
SetForegroundWindow(hWnd);
175-
if (GetForegroundWindow() != hWnd)
176-
{
177-
SwitchToThisWindow(hWnd, TRUE);
178-
Sleep(2);
179-
SetForegroundWindow(hWnd);
180-
}
181-
SetActiveWindow(hWnd);
182-
}
183-
return TRUE;
184168
case WM_CLOSE:
185169
EndDialog(hWnd, IDCANCEL);
186170
return TRUE;

src/baseopenasdlg.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class CBaseOpenAsDlg : public CImpDialog
2020
UINT m_uBrowseTitleId;
2121
IMMERSIVE_OPENWITH_FLAGS m_flags;
2222
bool m_fPreregistered;
23-
bool m_fShown;
2423

2524
INT_PTR CALLBACK v_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
2625
int _FindItemIndex(LPCWSTR lpszPath);

src/impdialog.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@ INT_PTR CALLBACK CImpDialog::s_DlgProc(
2020
);
2121
}
2222
}
23+
// For some reason, initializing through the server doesn't activate the window.
24+
// Let's activate it manually when it's shown.
25+
else if (uMsg == WM_WINDOWPOSCHANGED)
26+
{
27+
CImpDialog *pThis = (CImpDialog *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
28+
if (pThis && ((LPWINDOWPOS)lParam)->flags & SWP_SHOWWINDOW && !pThis->m_fShown)
29+
{
30+
pThis->m_fShown = true;
31+
SetForegroundWindow(hWnd);
32+
if (GetForegroundWindow() != hWnd)
33+
{
34+
SwitchToThisWindow(hWnd, TRUE);
35+
Sleep(2);
36+
SetForegroundWindow(hWnd);
37+
}
38+
SetActiveWindow(hWnd);
39+
}
40+
}
2341

2442
CImpDialog *pThis = (CImpDialog *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
2543
if (pThis)

src/impdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class CImpDialog
1111
HWND m_hWnd;
1212
HINSTANCE m_hInst;
1313
UINT m_uDlgId;
14+
bool m_fShown;
1415

1516
virtual INT_PTR CALLBACK v_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) = 0;
1617

0 commit comments

Comments
 (0)