mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[OSK] Implement "Always on Top" feature (#1729)
This commit is contained in:
parent
d3cdbad206
commit
b292acb5f7
21 changed files with 94 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -26,6 +26,7 @@ typedef struct
|
|||
BOOL bShowWarning;
|
||||
BOOL bIsEnhancedKeyboard;
|
||||
BOOL bSoundClick;
|
||||
BOOL bAlwaysOnTop;
|
||||
INT PosX;
|
||||
INT PosY;
|
||||
} OSK_GLOBALS;
|
||||
|
|
|
@ -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;
|
||||
|
@ -130,6 +131,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);
|
||||
return TRUE;
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue