Skip to content

Commit

Permalink
[EXPLORER] -Rewrite taskbar settings routines and dialog
Browse files Browse the repository at this point in the history
- Rewrite the taskbar settings and start menu settings property sheets.
- All settings in the taskbar settings property sheet can be loaded and saved properly except for the quick launch one which will be implemented later.
- Implement toggling lock, autohide and always on top. The rest will be implemented later.
  • Loading branch information
yagoulas committed Oct 31, 2017
1 parent cc578af commit 2ed535d
Show file tree
Hide file tree
Showing 9 changed files with 395 additions and 606 deletions.
2 changes: 1 addition & 1 deletion base/shell/explorer/CMakeLists.txt
@@ -1,7 +1,7 @@
PROJECT(SHELL)

set_cpp(WITH_RUNTIME)

add_definitions(-D_ATL_NO_EXCEPTIONS)
include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)

list(APPEND SOURCE
Expand Down
3 changes: 2 additions & 1 deletion base/shell/explorer/explorer.cpp
Expand Up @@ -127,7 +127,8 @@ StartWithDesktop(IN HINSTANCE hInstance)
hExplorerInstance = hInstance;
hProcessHeap = GetProcessHeap();

LoadTaskBarSettings();
g_TaskbarSettings.Load();

InitCommonControls();
OleInitialize(NULL);

Expand Down
55 changes: 31 additions & 24 deletions base/shell/explorer/precomp.h
Expand Up @@ -27,6 +27,7 @@
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <atlstr.h>
#include <shellapi.h>
#include <shlobj.h>
#include <shlwapi.h>
Expand All @@ -40,6 +41,7 @@
#include <undocshell.h>

#include <rosctrls.h>
#include <rosdlgs.h>
#include <shellutils.h>

#include "tmschema.h"
Expand Down Expand Up @@ -125,6 +127,7 @@ HRESULT WINAPI _CBandSite_CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void
*/

#define TWM_OPENSTARTMENU (WM_USER + 260)
#define TWM_SETTINGSCHANGED (WM_USER + 300)

extern const GUID IID_IShellDesktopTray;

Expand Down Expand Up @@ -181,35 +184,39 @@ TrayMessageLoop(IN OUT ITrayWindow *Tray);
* settings.c
*/

/* Structure to hold non-default options*/
typedef struct _TASKBAR_SETTINGS
typedef struct _TW_STUCKRECTS2
{
DWORD cbSize;
LONG Unknown;
union
{
DWORD dwFlags;
struct
{
DWORD AutoHide : 1;
DWORD AlwaysOnTop : 1;
DWORD SmallIcons : 1;
DWORD HideClock : 1;
};
};
DWORD Position;
SIZE Size;
RECT Rect;
} TW_STRUCKRECTS2, *PTW_STUCKRECTS2;

struct TaskbarSettings
{
BOOL bLock;
BOOL bAutoHide;
BOOL bAlwaysOnTop;
BOOL bGroupButtons;
BOOL bShowQuickLaunch;
BOOL bShowClock;
BOOL bShowSeconds;
BOOL bHideInactiveIcons;
} TASKBAR_SETTINGS, *PTASKBAR_SETTINGS;

extern TASKBAR_SETTINGS TaskBarSettings;

VOID
LoadTaskBarSettings(VOID);
TW_STRUCKRECTS2 sr;

VOID
SaveTaskBarSettings(VOID);
BOOL Load();
BOOL Save();
};

BOOL
LoadSettingDword(IN LPCWSTR pszKeyName,
IN LPCWSTR pszValueName,
OUT DWORD &dwValue);
BOOL
SaveSettingDword(IN LPCWSTR pszKeyName,
IN LPCWSTR pszValueName,
IN DWORD dwValue);
extern TaskbarSettings g_TaskbarSettings;

/*
* shellservice.cpp
Expand All @@ -229,7 +236,7 @@ ProcessStartupItems(VOID);
*/

VOID
DisplayTrayProperties(IN HWND hwndOwner);
DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar);

/*
* desktop.cpp
Expand Down Expand Up @@ -344,7 +351,7 @@ VOID
UnregisterTrayNotifyWndClass(VOID);

HWND
CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow, IN BOOL bHideClock, CTrayNotifyWnd** ppTrayNotify);
CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow, CTrayNotifyWnd** ppTrayNotify);

BOOL
TrayNotify_NotifyIconCmd(CTrayNotifyWnd* pTrayNotify, IN WPARAM wParam, IN LPARAM lParam);
Expand Down
2 changes: 2 additions & 0 deletions base/shell/explorer/resource.h
Expand Up @@ -107,6 +107,7 @@
\*******************************************************************************/

/* Taskbar Page */
#define IDC_TASKBARPROP_FIRST_CMD 1000
#define IDC_TASKBARPROP_HIDEICONS 1000
#define IDC_TASKBARPROP_ICONCUST 1007
#define IDC_TASKBARPROP_ONTOP 1101
Expand All @@ -116,6 +117,7 @@
#define IDC_TASKBARPROP_LOCK 1105
#define IDC_TASKBARPROP_SECONDS 1106
#define IDC_TASKBARPROP_SHOWQL 1107
#define IDC_TASKBARPROP_LAST_CMD 1107
#define IDC_TASKBARPROP_TASKBARBITMAP 1111
#define IDC_TASKBARPROP_NOTIFICATIONBITMAP 1112

Expand Down
106 changes: 41 additions & 65 deletions base/shell/explorer/settings.cpp
Expand Up @@ -20,85 +20,61 @@

#include "precomp.h"

TASKBAR_SETTINGS TaskBarSettings;
const WCHAR szSettingsKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer";
const WCHAR szAdvancedSettingsKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";
TaskbarSettings g_TaskbarSettings;

VOID
LoadTaskBarSettings(VOID)
BOOL TaskbarSettings::Save()
{
DWORD dwValue = NULL;

LoadSettingDword(szAdvancedSettingsKey, L"TaskbarSizeMove", dwValue);
TaskBarSettings.bLock = (dwValue == 0);

LoadSettingDword(szAdvancedSettingsKey, L"ShowSeconds", dwValue);
TaskBarSettings.bShowSeconds = (dwValue != 0);

LoadSettingDword(szSettingsKey, L"EnableAutotray", dwValue);
TaskBarSettings.bHideInactiveIcons = (dwValue != 0);

LoadSettingDword(szAdvancedSettingsKey, L"TaskbarGlomming", dwValue);
TaskBarSettings.bGroupButtons = (dwValue != 0);

TaskBarSettings.bShowQuickLaunch = TRUE; //FIXME: Where is this stored, and how?

/* FIXME: The following settings are stored in stuckrects2, do they have to be load here too? */
TaskBarSettings.bShowClock = TRUE;
TaskBarSettings.bAutoHide = FALSE;
TaskBarSettings.bAlwaysOnTop = FALSE;
SHSetValueW(hkExplorer, NULL, L"EnableAutotray", REG_DWORD, &bHideInactiveIcons, sizeof(bHideInactiveIcons));
SHSetValueW(hkExplorer, L"Advanced", L"ShowSeconds", REG_DWORD, &bShowSeconds, sizeof(bShowSeconds));
SHSetValueW(hkExplorer, L"Advanced", L"TaskbarGlomming", REG_DWORD, &bGroupButtons, sizeof(bGroupButtons));
BOOL bAllowSizeMove = !bLock;
SHSetValueW(hkExplorer, L"Advanced", L"TaskbarSizeMove", REG_DWORD, &bAllowSizeMove, sizeof(bAllowSizeMove));
sr.cbSize = sizeof(sr);
SHSetValueW(hkExplorer, L"StuckRects2", L"Settings", REG_BINARY, &sr, sizeof(sr));

/* TODO: AutoHide writes something to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components\0 figure out what and why */
return TRUE;
}

VOID
SaveTaskBarSettings(VOID)
BOOL TaskbarSettings::Load()
{
SaveSettingDword(szAdvancedSettingsKey, L"TaskbarSizeMove", TaskBarSettings.bLock);
SaveSettingDword(szAdvancedSettingsKey, L"ShowSeconds", TaskBarSettings.bShowSeconds);
SaveSettingDword(szSettingsKey, L"EnableAutotray", TaskBarSettings.bHideInactiveIcons);
SaveSettingDword(szAdvancedSettingsKey, L"TaskbarGlomming", TaskBarSettings.bGroupButtons);

/* FIXME: Show Clock, AutoHide and Always on top are stored in the stuckrects2 key but are not written to it with a click on apply. How is this done instead?
AutoHide writes something to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components\0 figure out what and why */
}
DWORD dwRet, cbSize, dwValue = NULL;

BOOL
LoadSettingDword(IN LPCWSTR pszKeyName,
IN LPCWSTR pszValueName,
OUT DWORD &dwValue)
{
BOOL ret = FALSE;
HKEY hKey;
cbSize = sizeof(dwValue);
dwRet = SHGetValueW(hkExplorer, L"Advanced", L"TaskbarSizeMove", NULL, &dwValue, &cbSize);
bLock = (dwRet == ERROR_SUCCESS) ? (dwValue == 0) : TRUE;

if (RegOpenKeyW(HKEY_CURRENT_USER, pszKeyName, &hKey) == ERROR_SUCCESS)
{
DWORD dwValueLength, dwType;
dwRet = SHGetValueW(hkExplorer, L"Advanced", L"ShowSeconds", NULL, &dwValue, &cbSize);
bShowSeconds = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE;

dwValueLength = sizeof(dwValue);
ret = RegQueryValueExW(hKey, pszValueName, NULL, &dwType, (PBYTE)&dwValue, &dwValueLength) == ERROR_SUCCESS && dwType == REG_DWORD;

RegCloseKey(hKey);
}

return ret;
}
dwRet = SHGetValueW(hkExplorer, L"Advanced", L"TaskbarGlomming", NULL, &dwValue, &cbSize);
bGroupButtons = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE;

BOOL
SaveSettingDword(IN LPCWSTR pszKeyName,
IN LPCWSTR pszValueName,
IN DWORD dwValue)
{
BOOL ret = FALSE;
HKEY hKey;
dwRet = SHGetValueW(hkExplorer, NULL, L"EnableAutotray", NULL, &dwValue, &cbSize);
bHideInactiveIcons = (dwRet == ERROR_SUCCESS) ? (dwValue != 0) : FALSE;

if (RegCreateKeyW(HKEY_CURRENT_USER, pszKeyName, &hKey) == ERROR_SUCCESS)
{
ret = RegSetValueExW(hKey, pszValueName, 0, REG_DWORD, (PBYTE)&dwValue, sizeof(dwValue)) == ERROR_SUCCESS;
cbSize = sizeof(sr);
dwRet = SHGetValueW(hkExplorer, L"StuckRects2", L"Settings", NULL, &sr, &cbSize);

RegCloseKey(hKey);
/* Make sure we have correct values here */
if (dwRet != ERROR_SUCCESS || sr.cbSize != sizeof(sr) || cbSize != sizeof(sr))
{
sr.Position = ABE_BOTTOM;
sr.AutoHide = FALSE;
sr.AlwaysOnTop = TRUE;
sr.SmallIcons = TRUE;
sr.HideClock = FALSE;
sr.Rect.left = sr.Rect.top = 0;
sr.Rect.bottom = sr.Rect.right = 1;
sr.Size.cx = sr.Size.cy = 0;
}
else
{
if (sr.Position > ABE_BOTTOM)
sr.Position = ABE_BOTTOM;
}

return ret;
return TRUE;
}

/* EOF */
13 changes: 13 additions & 0 deletions base/shell/explorer/taskswnd.cpp
Expand Up @@ -1735,6 +1735,18 @@ class CTaskSwitchWnd :
return TRUE;
}

LRESULT OnTaskbarSettingsChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
TaskbarSettings* newSettings = (TaskbarSettings*)lParam;
if (newSettings->bGroupButtons != g_TaskbarSettings.bGroupButtons)
{
/* TODO: Toggle grouping */
g_TaskbarSettings.bGroupButtons = newSettings->bGroupButtons;
}

return 0;
}

LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
LRESULT Ret = 0;
Expand Down Expand Up @@ -1828,6 +1840,7 @@ class CTaskSwitchWnd :
MESSAGE_HANDLER(WM_NOTIFY, OnNotify)
MESSAGE_HANDLER(TSWM_ENABLEGROUPING, OnEnableGrouping)
MESSAGE_HANDLER(TSWM_UPDATETASKBARPOS, OnUpdateTaskbarPos)
MESSAGE_HANDLER(TWM_SETTINGSCHANGED, OnTaskbarSettingsChanged)
MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
MESSAGE_HANDLER(WM_TIMER, OnTimer)
MESSAGE_HANDLER(WM_SETFONT, OnSetFont)
Expand Down

0 comments on commit 2ed535d

Please sign in to comment.