https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b292acb5f78608ee6ef95…
commit b292acb5f78608ee6ef951daa404b95fee12fd64
Author: Bișoc George <fraizeraust99(a)gmail.com>
AuthorDate: Mon Jul 15 15:59:06 2019 +0200
Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
CommitDate: Mon Jul 15 15:59:06 2019 +0200
[OSK] Implement "Always on Top" feature (#1729)
---
base/applications/osk/lang/ar-DZ.rc | 2 +-
base/applications/osk/lang/cs-CZ.rc | 2 +-
base/applications/osk/lang/de-DE.rc | 2 +-
base/applications/osk/lang/en-GB.rc | 2 +-
base/applications/osk/lang/en-US.rc | 2 +-
base/applications/osk/lang/es-ES.rc | 2 +-
base/applications/osk/lang/et-EE.rc | 2 +-
base/applications/osk/lang/fr-CA.rc | 2 +-
base/applications/osk/lang/fr-FR.rc | 2 +-
base/applications/osk/lang/he-IL.rc | 2 +-
base/applications/osk/lang/id-ID.rc | 2 +-
base/applications/osk/lang/it-IT.rc | 2 +-
base/applications/osk/lang/pl-PL.rc | 2 +-
base/applications/osk/lang/ro-RO.rc | 2 +-
base/applications/osk/lang/ru-RU.rc | 2 +-
base/applications/osk/lang/tr-TR.rc | 2 +-
base/applications/osk/lang/zh-CN.rc | 2 +-
base/applications/osk/lang/zh-TW.rc | 2 +-
base/applications/osk/main.c | 38 +++++++++++++++++++++++++++++++--
base/applications/osk/main.h | 1 +
base/applications/osk/settings.c | 42 ++++++++++++++++++++++++++++++++++---
21 files changed, 94 insertions(+), 23 deletions(-)
diff --git a/base/applications/osk/lang/ar-DZ.rc b/base/applications/osk/lang/ar-DZ.rc
index edd4536dd68..f9cda704bcf 100644
--- a/base/applications/osk/lang/ar-DZ.rc
+++ b/base/applications/osk/lang/ar-DZ.rc
@@ -268,7 +268,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/cs-CZ.rc b/base/applications/osk/lang/cs-CZ.rc
index 5360c7075d5..2802a978f97 100644
--- a/base/applications/osk/lang/cs-CZ.rc
+++ b/base/applications/osk/lang/cs-CZ.rc
@@ -268,7 +268,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/de-DE.rc b/base/applications/osk/lang/de-DE.rc
index dba2dc1788f..419fb87a96c 100644
--- a/base/applications/osk/lang/de-DE.rc
+++ b/base/applications/osk/lang/de-DE.rc
@@ -269,7 +269,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/en-GB.rc b/base/applications/osk/lang/en-GB.rc
index ab04edc3a3f..8665669447e 100644
--- a/base/applications/osk/lang/en-GB.rc
+++ b/base/applications/osk/lang/en-GB.rc
@@ -269,7 +269,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/en-US.rc b/base/applications/osk/lang/en-US.rc
index d955621f20b..f852a7e6293 100644
--- a/base/applications/osk/lang/en-US.rc
+++ b/base/applications/osk/lang/en-US.rc
@@ -268,7 +268,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/es-ES.rc b/base/applications/osk/lang/es-ES.rc
index 319fe387d00..e09e8f88dbc 100644
--- a/base/applications/osk/lang/es-ES.rc
+++ b/base/applications/osk/lang/es-ES.rc
@@ -270,7 +270,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/et-EE.rc b/base/applications/osk/lang/et-EE.rc
index c527e7e4497..c449c8ed4fc 100644
--- a/base/applications/osk/lang/et-EE.rc
+++ b/base/applications/osk/lang/et-EE.rc
@@ -268,7 +268,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/fr-CA.rc b/base/applications/osk/lang/fr-CA.rc
index 18636d9614b..c7857d406be 100644
--- a/base/applications/osk/lang/fr-CA.rc
+++ b/base/applications/osk/lang/fr-CA.rc
@@ -269,7 +269,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/fr-FR.rc b/base/applications/osk/lang/fr-FR.rc
index ba05f9f1953..2764cf9b57e 100644
--- a/base/applications/osk/lang/fr-FR.rc
+++ b/base/applications/osk/lang/fr-FR.rc
@@ -269,7 +269,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/he-IL.rc b/base/applications/osk/lang/he-IL.rc
index fb7977d8475..cadeb7037dd 100644
--- a/base/applications/osk/lang/he-IL.rc
+++ b/base/applications/osk/lang/he-IL.rc
@@ -268,7 +268,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/id-ID.rc b/base/applications/osk/lang/id-ID.rc
index 9fc8d1d73c9..f916f2932ef 100644
--- a/base/applications/osk/lang/id-ID.rc
+++ b/base/applications/osk/lang/id-ID.rc
@@ -268,7 +268,7 @@ BEGIN
POPUP "&Pengaturan"
BEGIN
- MENUITEM "&Selalu di Atas", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "&Selalu di Atas", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Gunakan Suara", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/it-IT.rc b/base/applications/osk/lang/it-IT.rc
index b4ba448adfd..f2b3649fbf5 100644
--- a/base/applications/osk/lang/it-IT.rc
+++ b/base/applications/osk/lang/it-IT.rc
@@ -270,7 +270,7 @@ BEGIN
POPUP "Impostazioni"
BEGIN
- MENUITEM "Sempre in primo piano", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Sempre in primo piano", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Usa suono al click", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/pl-PL.rc b/base/applications/osk/lang/pl-PL.rc
index 7997b9790ed..1844ff89514 100644
--- a/base/applications/osk/lang/pl-PL.rc
+++ b/base/applications/osk/lang/pl-PL.rc
@@ -268,7 +268,7 @@ BEGIN
POPUP "Ust&awienia"
BEGIN
- MENUITEM "&Zawsze na wierzchu", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "&Zawsze na wierzchu", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Użyj dźwięku kliknięcia", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/ro-RO.rc b/base/applications/osk/lang/ro-RO.rc
index f47416acbfe..bc30611f975 100644
--- a/base/applications/osk/lang/ro-RO.rc
+++ b/base/applications/osk/lang/ro-RO.rc
@@ -269,7 +269,7 @@ BEGIN
POPUP "Setări"
BEGIN
- MENUITEM "Întotdeauna în sus", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Întotdeauna în sus", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Folosește sunetul de clic", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/ru-RU.rc b/base/applications/osk/lang/ru-RU.rc
index 42f6b43e358..c2878b717ee 100644
--- a/base/applications/osk/lang/ru-RU.rc
+++ b/base/applications/osk/lang/ru-RU.rc
@@ -268,7 +268,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/tr-TR.rc b/base/applications/osk/lang/tr-TR.rc
index fb40d8c76b9..179545d9bb5 100644
--- a/base/applications/osk/lang/tr-TR.rc
+++ b/base/applications/osk/lang/tr-TR.rc
@@ -268,7 +268,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/zh-CN.rc b/base/applications/osk/lang/zh-CN.rc
index 5f8b49ec049..2ccaa37269b 100644
--- a/base/applications/osk/lang/zh-CN.rc
+++ b/base/applications/osk/lang/zh-CN.rc
@@ -271,7 +271,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/lang/zh-TW.rc b/base/applications/osk/lang/zh-TW.rc
index fbb62ff79fe..02d980a6cfc 100644
--- a/base/applications/osk/lang/zh-TW.rc
+++ b/base/applications/osk/lang/zh-TW.rc
@@ -270,7 +270,7 @@ BEGIN
POPUP "Settings"
BEGIN
- MENUITEM "Always on Top", IDM_ON_TOP, CHECKED, GRAYED
+ MENUITEM "Always on Top", IDM_ON_TOP, CHECKED
MENUITEM SEPARATOR
MENUITEM "&Use Click Sound", IDM_CLICK_SOUND
MENUITEM SEPARATOR
diff --git a/base/applications/osk/main.c b/base/applications/osk/main.c
index 939326d0da7..4bb7f5010cb 100644
--- a/base/applications/osk/main.c
+++ b/base/applications/osk/main.c
@@ -213,8 +213,20 @@ int OSK_DlgInitDialog(HWND hDlg)
}
}
- /* Move the dialog according to the placement coordination */
- SetWindowPos(hDlg, HWND_TOP, Globals.PosX, Globals.PosY, 0, 0, SWP_NOSIZE);
+ /*
+ Place the window (with respective placement coordinates) as topmost, above
+ every window which are not on top or are at the bottom of the Z order.
+ */
+ if (Globals.bAlwaysOnTop)
+ {
+ CheckMenuItem(GetMenu(hDlg), IDM_ON_TOP, MF_BYCOMMAND | MF_CHECKED);
+ SetWindowPos(hDlg, HWND_TOPMOST, Globals.PosX, Globals.PosY, 0, 0, SWP_NOSIZE);
+ }
+ else
+ {
+ CheckMenuItem(GetMenu(hDlg), IDM_ON_TOP, MF_BYCOMMAND | MF_UNCHECKED);
+ SetWindowPos(hDlg, HWND_NOTOPMOST, Globals.PosX, Globals.PosY, 0, 0,
SWP_NOSIZE);
+ }
/* Set icon on visual buttons */
OSK_SetImage(SCAN_CODE_15, IDI_BACK);
@@ -637,6 +649,28 @@ INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam,
LPARAM lParam)
break;
}
+ case IDM_ON_TOP:
+ {
+ /*
+ Check the condition state before disabling/enabling the menu
+ item and change the topmost order.
+ */
+ if (!Globals.bAlwaysOnTop)
+ {
+ Globals.bAlwaysOnTop = TRUE;
+ CheckMenuItem(GetMenu(hDlg), IDM_ON_TOP, MF_BYCOMMAND |
MF_CHECKED);
+ SetWindowPos(hDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE |
SWP_NOMOVE);
+ }
+ else
+ {
+ Globals.bAlwaysOnTop = FALSE;
+ CheckMenuItem(GetMenu(hDlg), IDM_ON_TOP, MF_BYCOMMAND |
MF_UNCHECKED);
+ SetWindowPos(hDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE |
SWP_NOMOVE);
+ }
+
+ break;
+ }
+
case IDM_ABOUT:
{
OSK_About();
diff --git a/base/applications/osk/main.h b/base/applications/osk/main.h
index da4cf2a7bae..5ce6a7acb7c 100644
--- a/base/applications/osk/main.h
+++ b/base/applications/osk/main.h
@@ -26,6 +26,7 @@ typedef struct
BOOL bShowWarning;
BOOL bIsEnhancedKeyboard;
BOOL bSoundClick;
+ BOOL bAlwaysOnTop;
INT PosX;
INT PosY;
} OSK_GLOBALS;
diff --git a/base/applications/osk/settings.c b/base/applications/osk/settings.c
index d7dab32eaf7..5d403e89d6d 100644
--- a/base/applications/osk/settings.c
+++ b/base/applications/osk/settings.c
@@ -16,13 +16,14 @@ BOOL LoadDataFromRegistry()
{
HKEY hKey;
LONG lResult;
- DWORD dwShowWarningData, dwLayout, dwSoundOnClick, dwPositionLeft, dwPositionTop;
+ DWORD dwShowWarningData, dwLayout, dwSoundOnClick, dwPositionLeft, dwPositionTop,
dwAlwaysOnTop;
DWORD cbData = sizeof(DWORD);
- /* Set the structure members to TRUE (and the bSoundClick member to FALSE) */
+ /* Initialize the registry application settings */
Globals.bShowWarning = TRUE;
Globals.bIsEnhancedKeyboard = TRUE;
Globals.bSoundClick = FALSE;
+ Globals.bAlwaysOnTop = TRUE;
/* Set the coordinate values to default */
Globals.PosX = CW_USEDEFAULT;
@@ -129,6 +130,23 @@ BOOL LoadDataFromRegistry()
/* Load the Y value data of the dialog's coordinate */
Globals.PosY = dwPositionTop;
+
+ lResult = RegQueryValueExW(hKey,
+ L"AlwaysOnTop",
+ 0,
+ 0,
+ (BYTE *)&dwAlwaysOnTop,
+ &cbData);
+
+ if (lResult != ERROR_SUCCESS)
+ {
+ /* Bail out and return FALSE if we fail */
+ RegCloseKey(hKey);
+ return FALSE;
+ }
+
+ /* Load the window state value data */
+ Globals.bAlwaysOnTop = (dwAlwaysOnTop != 0);
/* If we're here then we succeed, close the key and return TRUE */
RegCloseKey(hKey);
@@ -139,7 +157,7 @@ BOOL SaveDataToRegistry()
{
HKEY hKey;
LONG lResult;
- DWORD dwShowWarningData, dwLayout, dwSoundOnClick, dwPositionLeft, dwPositionTop;
+ DWORD dwShowWarningData, dwLayout, dwSoundOnClick, dwPositionLeft, dwPositionTop,
dwAlwaysOnTop;
WINDOWPLACEMENT wp;
/* Set the structure length and retrieve the dialog's placement */
@@ -253,6 +271,24 @@ BOOL SaveDataToRegistry()
return FALSE;
}
+ /* Window top state value */
+ dwAlwaysOnTop = Globals.bAlwaysOnTop;
+
+ /* "Always on Top" state value key */
+ lResult = RegSetValueExW(hKey,
+ L"AlwaysOnTop",
+ 0,
+ REG_DWORD,
+ (BYTE *)&dwAlwaysOnTop,
+ sizeof(dwAlwaysOnTop));
+
+ if (lResult != ERROR_SUCCESS)
+ {
+ /* Bail out and return FALSE if we fail */
+ RegCloseKey(hKey);
+ return FALSE;
+ }
+
/* If we're here then we succeed, close the key and return TRUE */
RegCloseKey(hKey);
return TRUE;