From a1f686d1b4f74d414ca0909b2af73bb10e0ec597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 31 Mar 2022 22:43:29 +0200 Subject: Fix child window focus on re-activation. --- c/main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'c/main.c') diff --git a/c/main.c b/c/main.c index 09227b9..b7986c1 100644 --- a/c/main.c +++ b/c/main.c @@ -9,6 +9,7 @@ HFONT HfNormal; HFONT HfBold; HMENU HPopupMenu; +HWND HFocus; HWND HWnd; static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); static INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM); @@ -36,7 +37,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, tszErr = TEXT("Could not attach databases."); if (!Attach()) goto f; - /* Initialize window. */ + /* Initialize common controls, load menu and register window class. */ icc.dwSize = sizeof(icc); icc.dwICC = ICC_WIN95_CLASSES; @@ -59,6 +60,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, tszErr = TEXT("Could not register window class."); if (!RegisterClassEx(&wc)) goto f; + /* Create window. */ + hWnd = CreateWindowEx( 0, TEXT("EpisodeBrowser"), @@ -69,7 +72,6 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, ); tszErr = TEXT("Could not create main window."); if (!hWnd) goto f; - SetupFonts(); ShowWindow(hWnd, nCmdShow); @@ -108,10 +110,12 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } case WM_CREATE: { + extern HWND HElv; HWnd = hWnd; DlvCreate(); ElvCreate(); UpdateTheme(); + SetFocus(HElv); break; } case WM_THEMECHANGED: @@ -120,13 +124,12 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_ACTIVATE: switch (wParam) { term_t t; - extern HWND HElv; case WA_INACTIVE: + HFocus = GetFocus(); break; case WA_ACTIVE: - SetFocus(HElv); - /* FALLTHROUGH */ case WA_CLICKACTIVE: + SetFocus(HFocus); t = T(0); P("track_episodes","update_tracked_episodes",0,t); ElvRedraw(); -- cgit v1.2.3