https://git.reactos.org/?p=reactos.git;a=commitdiff;h=aea948a79e231ef8f29b5…
commit aea948a79e231ef8f29b546902ae7427832a064f
Author: George Bișoc <george.bisoc(a)reactos.org>
AuthorDate: Mon May 4 12:06:22 2020 +0200
Commit: George Bișoc <george.bisoc(a)reactos.org>
CommitDate: Sat Apr 10 10:05:08 2021 +0200
[OSK] Handle the warning dialog box in its own thread
The dialog box at the startup of On-Screen Keyboard is displayed alongside with main
window. While the Microsoft's OSK in XP is written in MFC and OSK is actually a mere
window whereas our OSK is a dialog, the main dialog procedure call is superseded until the
user does something with the warning dialog box on startup.
Just create a thread for it and handle the dialog box on startup in its own thread.
---
base/applications/osk/main.c | 22 ++++++++++++++++++++--
base/applications/osk/precomp.h | 1 +
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/base/applications/osk/main.c b/base/applications/osk/main.c
index 6f6e8b81513..d7ab41c70b2 100644
--- a/base/applications/osk/main.c
+++ b/base/applications/osk/main.c
@@ -3,7 +3,7 @@
* LICENSE: GPL - See COPYING in the top level directory
* PURPOSE: On-screen keyboard.
* COPYRIGHT: Denis ROBERT
- * Copyright 2019 George Bișoc (george.bisoc(a)reactos.org)
+ * Copyright 2019-2020 George Bișoc (george.bisoc(a)reactos.org)
*/
/* INCLUDES *******************************************************************/
@@ -94,6 +94,20 @@ INT_PTR CALLBACK OSK_WarningProc(HWND hDlg, UINT Msg, WPARAM wParam,
LPARAM lPar
return FALSE;
}
+/***********************************************************************
+ *
+ * OSK_WarningDlgThread
+ *
+ * Thread procedure routine for the warning dialog box
+ */
+DWORD WINAPI OSK_WarningDlgThread(LPVOID lpParameter)
+{
+ HINSTANCE hInstance = (HINSTANCE)lpParameter;
+
+ DialogBoxW(hInstance, MAKEINTRESOURCEW(IDD_WARNINGDIALOG_OSK), Globals.hMainWnd,
OSK_WarningProc);
+ return 0;
+}
+
/***********************************************************************
*
* OSK_About
@@ -811,7 +825,11 @@ int WINAPI wWinMain(HINSTANCE hInstance,
/* If the member of the struct (bShowWarning) is set then display the dialog box */
if (Globals.bShowWarning)
{
- DialogBoxW(Globals.hInstance, MAKEINTRESOURCEW(IDD_WARNINGDIALOG_OSK),
Globals.hMainWnd, OSK_WarningProc);
+ /* If for whatever reason the thread fails to be created then handle the dialog
box in main thread... */
+ if (CreateThread(NULL, 0, OSK_WarningDlgThread, (PVOID)Globals.hInstance, 0,
NULL) == NULL)
+ {
+ DialogBoxW(Globals.hInstance, MAKEINTRESOURCEW(IDD_WARNINGDIALOG_OSK),
Globals.hMainWnd, OSK_WarningProc);
+ }
}
/* Before initializing the dialog execution, check if the chosen keyboard type is
standard or enhanced */
diff --git a/base/applications/osk/precomp.h b/base/applications/osk/precomp.h
index 53d45be8c84..3aa0767fbcc 100644
--- a/base/applications/osk/precomp.h
+++ b/base/applications/osk/precomp.h
@@ -65,6 +65,7 @@ BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl);
BOOL OSK_ReleaseKey(WORD ScanCode);
INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
LRESULT APIENTRY OSK_ThemeHandler(HWND hDlg, NMCUSTOMDRAW *pNmDraw);
+DWORD WINAPI OSK_WarningDlgThread(LPVOID lpParameter);
int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
VOID OSK_RestoreDlgPlacement(HWND hDlg);
VOID OSK_RefreshLEDKeys(VOID);