Skip to content

Commit aa38063

Browse files
committed
Fix bug where starting from server would result in unfocused dialog
1 parent 18057d0 commit aa38063

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

src/baseopenasdlg.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,22 @@ 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;
168184
case WM_CLOSE:
169185
EndDialog(hWnd, IDCANCEL);
170186
return TRUE;

src/baseopenasdlg.h

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

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

0 commit comments

Comments
 (0)