From 1aa0b809e122fd15b3669dbb90952fb48fe49ca2 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 27 Aug 2019 17:23:17 +0200 Subject: [PATCH] Clean up diablo_find_window --- Source/diablo.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 76a6949f8..ae6a6a956 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -484,25 +484,24 @@ void diablo_init_screen() BOOL diablo_find_window(LPCSTR lpClassName) { - HWND result; // eax - HWND v2; // esi - HWND v3; // eax - HWND v4; // edi - - result = FindWindow(lpClassName, 0); - v2 = result; - if (!result) - return 0; + HWND hWnd, active; + + hWnd = FindWindow(lpClassName, 0); + if (!hWnd) + return FALSE; + + active = GetLastActivePopup(hWnd); + if (active) + hWnd = active; - v3 = GetLastActivePopup(result); - if (v3) - v2 = v3; - v4 = GetTopWindow(v2); - if (!v4) - v4 = v2; - SetForegroundWindow(v2); - SetFocus(v4); - return 1; + active = GetTopWindow(hWnd); + if (!active) + active = hWnd; + + SetForegroundWindow(hWnd); + SetFocus(active); + + return TRUE; } void diablo_reload_process(HINSTANCE hInstance)