2015-11-21 12:49:38 +00:00
|
|
|
/*
|
2024-03-19 22:32:52 +00:00
|
|
|
* PROJECT: ReactOS Explorer
|
|
|
|
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
|
|
|
* PURPOSE: "Customize Start Menu" dialog
|
|
|
|
* COPYRIGHT: Copyright 2006-2007 Thomas Weidenmueller <w3seek@reactos.org>
|
|
|
|
* Copyright 2015 Robert Naumann <gonzomdx@gmail.com>
|
|
|
|
* Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
2015-11-21 12:49:38 +00:00
|
|
|
*/
|
2015-12-05 18:29:33 +00:00
|
|
|
|
2015-11-21 12:49:38 +00:00
|
|
|
#include "precomp.h"
|
|
|
|
|
2024-03-19 22:32:52 +00:00
|
|
|
// TreeView checkbox state indexes (Use with INDEXTOSTATEIMAGEMASK macro)
|
2024-03-11 11:18:07 +00:00
|
|
|
#define I_UNCHECKED 1
|
2024-02-27 11:41:43 +00:00
|
|
|
#define I_CHECKED 2
|
|
|
|
|
2016-10-01 15:57:29 +00:00
|
|
|
// TODO: Windows Explorer appears to be calling NewLinkHere / ConfigStartMenu directly for both items.
|
2016-06-04 14:09:20 +00:00
|
|
|
VOID OnAddStartMenuItems(HWND hDlg)
|
2015-11-22 09:28:45 +00:00
|
|
|
{
|
|
|
|
WCHAR szPath[MAX_PATH];
|
|
|
|
|
2018-07-22 16:05:50 +00:00
|
|
|
if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROGRAMS, NULL, 0, szPath)))
|
2015-11-22 09:28:45 +00:00
|
|
|
{
|
|
|
|
WCHAR szCommand[MAX_PATH] = L"appwiz.cpl,NewLinkHere ";
|
2016-06-04 22:51:19 +00:00
|
|
|
if (SUCCEEDED(StringCchCatW(szCommand, _countof(szCommand), szPath)))
|
2015-11-22 09:28:45 +00:00
|
|
|
ShellExecuteW(hDlg, L"open", L"rundll32.exe", szCommand, NULL, SW_SHOWNORMAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-01 15:57:29 +00:00
|
|
|
VOID OnRemoveStartmenuItems(HWND hDlg)
|
|
|
|
{
|
|
|
|
ShellExecuteW(hDlg, L"open", L"rundll32.exe", L"appwiz.cpl,ConfigStartMenu", NULL, SW_SHOWNORMAL);
|
|
|
|
}
|
|
|
|
|
2015-11-22 09:28:45 +00:00
|
|
|
VOID OnAdvancedStartMenuItems()
|
|
|
|
{
|
|
|
|
WCHAR szPath[MAX_PATH];
|
|
|
|
|
2016-06-04 14:09:20 +00:00
|
|
|
if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_STARTMENU, NULL, 0, szPath)))
|
2015-11-22 09:28:45 +00:00
|
|
|
{
|
|
|
|
ShellExecuteW(NULL, L"explore", szPath, NULL, NULL, SW_SHOWNORMAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-27 11:41:43 +00:00
|
|
|
static BOOL RecentHasShortcut(HWND hwnd)
|
2015-11-22 09:28:45 +00:00
|
|
|
{
|
2024-02-27 11:41:43 +00:00
|
|
|
WCHAR szPath[MAX_PATH];
|
|
|
|
if (FAILED(SHGetFolderPathW(hwnd, CSIDL_RECENT | CSIDL_FLAG_CREATE, NULL, 0, szPath)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
// Find shortcut files in Recent
|
|
|
|
WIN32_FIND_DATAW find;
|
|
|
|
PathAppendW(szPath, L"*.lnk");
|
|
|
|
HANDLE hFind = FindFirstFileW(szPath, &find);
|
|
|
|
if (hFind == INVALID_HANDLE_VALUE)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
FindClose(hFind);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID OnClearRecentItems(HWND hwnd)
|
|
|
|
{
|
|
|
|
SHAddToRecentDocs(SHARD_PIDL, NULL);
|
|
|
|
EnableWindow(GetDlgItem(hwnd, IDC_CLASSICSTART_CLEAR), RecentHasShortcut(hwnd));
|
|
|
|
}
|
|
|
|
|
2024-03-19 22:32:52 +00:00
|
|
|
struct CUSTOM_ENTRY;
|
2024-02-27 11:41:43 +00:00
|
|
|
|
2024-03-19 22:32:52 +00:00
|
|
|
typedef BOOL (CALLBACK *FN_CUSTOM_GET)(const CUSTOM_ENTRY *entry);
|
|
|
|
typedef VOID (CALLBACK *FN_CUSTOM_SET)(const CUSTOM_ENTRY *entry, BOOL bValue);
|
|
|
|
|
|
|
|
struct CUSTOM_ENTRY
|
2024-02-27 11:41:43 +00:00
|
|
|
{
|
|
|
|
LPARAM id;
|
|
|
|
LPCWSTR name;
|
2024-03-11 11:18:07 +00:00
|
|
|
BOOL bDefaultValue;
|
2024-03-19 22:32:52 +00:00
|
|
|
FN_CUSTOM_GET fnGetValue;
|
|
|
|
FN_CUSTOM_SET fnSetValue;
|
2024-03-11 11:18:07 +00:00
|
|
|
RESTRICTIONS policy1, policy2;
|
2024-02-27 11:41:43 +00:00
|
|
|
};
|
|
|
|
|
2024-03-19 22:32:52 +00:00
|
|
|
static BOOL CALLBACK CustomGetAdvanced(const CUSTOM_ENTRY *entry)
|
|
|
|
{
|
|
|
|
return GetAdvancedBool(entry->name, entry->bDefaultValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VOID CALLBACK CustomSetAdvanced(const CUSTOM_ENTRY *entry, BOOL bValue)
|
|
|
|
{
|
|
|
|
SetAdvancedDword(entry->name, bValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL CALLBACK CustomGetSmallStartMenu(const CUSTOM_ENTRY *entry)
|
|
|
|
{
|
2024-03-22 12:15:22 +00:00
|
|
|
return g_TaskbarSettings.sr.SmSmallIcons;
|
2024-03-19 22:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static VOID CALLBACK CustomSetSmallStartMenu(const CUSTOM_ENTRY *entry, BOOL bValue)
|
|
|
|
{
|
2024-03-22 12:15:22 +00:00
|
|
|
g_TaskbarSettings.sr.SmSmallIcons = bValue;
|
2024-03-19 22:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const CUSTOM_ENTRY s_CustomEntries[] =
|
2024-02-27 11:41:43 +00:00
|
|
|
{
|
2024-03-11 12:58:30 +00:00
|
|
|
{
|
|
|
|
IDS_ADVANCED_DISPLAY_ADMINTOOLS, L"StartMenuAdminTools", TRUE,
|
2024-03-19 22:32:52 +00:00
|
|
|
CustomGetAdvanced, CustomSetAdvanced,
|
2024-03-11 12:58:30 +00:00
|
|
|
},
|
2024-03-11 11:18:07 +00:00
|
|
|
{
|
|
|
|
IDS_ADVANCED_DISPLAY_FAVORITES, L"StartMenuFavorites", FALSE,
|
2024-03-19 22:32:52 +00:00
|
|
|
CustomGetAdvanced, CustomSetAdvanced,
|
|
|
|
REST_NOFAVORITESMENU,
|
2024-03-11 11:18:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
IDS_ADVANCED_DISPLAY_LOG_OFF, L"StartMenuLogoff", FALSE,
|
2024-03-19 22:32:52 +00:00
|
|
|
CustomGetAdvanced, CustomSetAdvanced,
|
|
|
|
REST_STARTMENULOGOFF,
|
2024-03-11 11:18:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
IDS_ADVANCED_DISPLAY_RUN, L"StartMenuRun", TRUE,
|
2024-03-19 22:32:52 +00:00
|
|
|
CustomGetAdvanced, CustomSetAdvanced,
|
|
|
|
REST_NORUN,
|
2024-03-11 11:18:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
IDS_ADVANCED_EXPAND_MY_DOCUMENTS, L"CascadeMyDocuments", FALSE,
|
2024-03-19 22:32:52 +00:00
|
|
|
CustomGetAdvanced, CustomSetAdvanced,
|
|
|
|
REST_NOSMMYDOCS,
|
2024-03-11 11:18:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
IDS_ADVANCED_EXPAND_MY_PICTURES, L"CascadeMyPictures", FALSE,
|
2024-03-19 22:32:52 +00:00
|
|
|
CustomGetAdvanced, CustomSetAdvanced,
|
|
|
|
REST_NOSMMYPICS,
|
2024-03-11 11:18:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
IDS_ADVANCED_EXPAND_CONTROL_PANEL, L"CascadeControlPanel", FALSE,
|
2024-03-19 22:32:52 +00:00
|
|
|
CustomGetAdvanced, CustomSetAdvanced,
|
2024-03-11 11:18:07 +00:00
|
|
|
REST_NOSETFOLDERS, REST_NOCONTROLPANEL,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
IDS_ADVANCED_EXPAND_PRINTERS, L"CascadePrinters", FALSE,
|
2024-03-19 22:32:52 +00:00
|
|
|
CustomGetAdvanced, CustomSetAdvanced,
|
|
|
|
REST_NOSETFOLDERS,
|
2024-03-11 11:18:07 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
IDS_ADVANCED_EXPAND_NET_CONNECTIONS, L"CascadeNetworkConnections", FALSE,
|
2024-03-19 22:32:52 +00:00
|
|
|
CustomGetAdvanced, CustomSetAdvanced,
|
|
|
|
REST_NOSETFOLDERS, REST_NONETWORKCONNECTIONS,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
IDS_ADVANCED_SMALL_START_MENU, NULL, FALSE,
|
|
|
|
CustomGetSmallStartMenu, CustomSetSmallStartMenu,
|
2024-03-11 11:18:07 +00:00
|
|
|
},
|
2024-02-27 11:41:43 +00:00
|
|
|
};
|
|
|
|
|
2024-03-19 22:32:52 +00:00
|
|
|
static VOID AddCustomItem(HWND hTreeView, const CUSTOM_ENTRY *entry)
|
2024-02-27 11:41:43 +00:00
|
|
|
{
|
2024-03-11 11:18:07 +00:00
|
|
|
if (SHRestricted(entry->policy1) || SHRestricted(entry->policy2))
|
|
|
|
{
|
|
|
|
TRACE("%p: Restricted\n", entry->id);
|
|
|
|
return; // Restricted. Don't show
|
|
|
|
}
|
|
|
|
|
2024-02-27 11:41:43 +00:00
|
|
|
WCHAR szText[MAX_PATH];
|
|
|
|
LoadStringW(GetModuleHandleW(L"shell32.dll"), entry->id, szText, _countof(szText));
|
2024-03-19 22:32:52 +00:00
|
|
|
|
|
|
|
BOOL bChecked = entry->fnGetValue(entry);
|
|
|
|
TRACE("%p: %d\n", entry->id, bChecked);
|
|
|
|
|
|
|
|
TV_INSERTSTRUCT Insert = { TVI_ROOT, TVI_LAST, { TVIF_TEXT | TVIF_STATE | TVIF_PARAM } };
|
2024-02-27 11:41:43 +00:00
|
|
|
Insert.item.pszText = szText;
|
|
|
|
Insert.item.lParam = entry->id;
|
|
|
|
Insert.item.stateMask = TVIS_STATEIMAGEMASK;
|
2024-03-11 11:18:07 +00:00
|
|
|
Insert.item.state = INDEXTOSTATEIMAGEMASK(bChecked ? I_CHECKED : I_UNCHECKED);
|
2024-02-27 11:41:43 +00:00
|
|
|
TreeView_InsertItem(hTreeView, &Insert);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CustomizeClassic_OnInitDialog(HWND hwnd)
|
|
|
|
{
|
|
|
|
EnableWindow(GetDlgItem(hwnd, IDC_CLASSICSTART_CLEAR), RecentHasShortcut(hwnd));
|
|
|
|
|
|
|
|
HWND hTreeView = GetDlgItem(hwnd, IDC_CLASSICSTART_SETTINGS);
|
|
|
|
|
|
|
|
DWORD_PTR style = GetWindowLongPtrW(hTreeView, GWL_STYLE);
|
|
|
|
SetWindowLongPtrW(hTreeView, GWL_STYLE, style | TVS_CHECKBOXES);
|
|
|
|
|
2024-03-19 22:32:52 +00:00
|
|
|
for (auto& entry : s_CustomEntries)
|
2024-02-27 11:41:43 +00:00
|
|
|
{
|
2024-03-19 22:32:52 +00:00
|
|
|
AddCustomItem(hTreeView, &entry);
|
2024-02-27 11:41:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL CustomizeClassic_OnOK(HWND hwnd)
|
|
|
|
{
|
|
|
|
HWND hTreeView = GetDlgItem(hwnd, IDC_CLASSICSTART_SETTINGS);
|
|
|
|
|
2024-03-11 23:17:05 +00:00
|
|
|
for (HTREEITEM hItem = TreeView_GetRoot(hTreeView);
|
2024-02-27 11:41:43 +00:00
|
|
|
hItem != NULL;
|
|
|
|
hItem = TreeView_GetNextVisible(hTreeView, hItem))
|
2015-11-22 09:28:45 +00:00
|
|
|
{
|
2024-03-19 22:32:52 +00:00
|
|
|
TV_ITEM item = { TVIF_PARAM | TVIF_STATE, hItem };
|
2024-02-27 11:41:43 +00:00
|
|
|
item.stateMask = TVIS_STATEIMAGEMASK;
|
|
|
|
TreeView_GetItem(hTreeView, &item);
|
|
|
|
|
2024-03-11 11:18:07 +00:00
|
|
|
BOOL bChecked = !!(item.state & INDEXTOSTATEIMAGEMASK(I_CHECKED));
|
2024-03-19 22:32:52 +00:00
|
|
|
for (auto& entry : s_CustomEntries)
|
2015-11-22 09:28:45 +00:00
|
|
|
{
|
2024-03-11 11:18:07 +00:00
|
|
|
if (SHRestricted(entry.policy1) || SHRestricted(entry.policy2))
|
|
|
|
continue;
|
|
|
|
|
2024-02-27 11:41:43 +00:00
|
|
|
if (item.lParam == entry.id)
|
|
|
|
{
|
2024-03-11 11:18:07 +00:00
|
|
|
TRACE("%p: %d\n", item.lParam, bChecked);
|
2024-03-19 22:32:52 +00:00
|
|
|
entry.fnSetValue(&entry, bChecked);
|
2024-02-27 11:41:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-06-04 14:09:20 +00:00
|
|
|
}
|
2015-12-05 18:29:33 +00:00
|
|
|
}
|
2024-02-27 11:41:43 +00:00
|
|
|
|
|
|
|
SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)L"TraySettings",
|
|
|
|
SMTO_ABORTIFHUNG, 200, NULL);
|
|
|
|
return TRUE;
|
2015-11-22 09:28:45 +00:00
|
|
|
}
|
|
|
|
|
2015-12-05 18:29:33 +00:00
|
|
|
INT_PTR CALLBACK CustomizeClassicProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
2015-11-21 12:49:38 +00:00
|
|
|
{
|
2020-01-31 11:09:00 +00:00
|
|
|
switch (Message)
|
2015-11-21 12:49:38 +00:00
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2024-02-27 11:41:43 +00:00
|
|
|
CustomizeClassic_OnInitDialog(hwnd);
|
2020-01-31 11:09:00 +00:00
|
|
|
return TRUE;
|
2015-11-21 12:49:38 +00:00
|
|
|
case WM_COMMAND:
|
2020-01-31 11:09:00 +00:00
|
|
|
switch (LOWORD(wParam))
|
2015-11-21 12:49:38 +00:00
|
|
|
{
|
2015-11-22 09:28:45 +00:00
|
|
|
case IDC_CLASSICSTART_ADD:
|
2016-06-04 14:09:20 +00:00
|
|
|
OnAddStartMenuItems(hwnd);
|
2020-01-31 11:09:00 +00:00
|
|
|
break;
|
2016-10-01 15:57:29 +00:00
|
|
|
case IDC_CLASSICSTART_REMOVE:
|
|
|
|
OnRemoveStartmenuItems(hwnd);
|
2020-01-31 11:09:00 +00:00
|
|
|
break;
|
2015-11-22 09:28:45 +00:00
|
|
|
case IDC_CLASSICSTART_ADVANCED:
|
|
|
|
OnAdvancedStartMenuItems();
|
2020-01-31 11:09:00 +00:00
|
|
|
break;
|
2015-11-22 09:28:45 +00:00
|
|
|
case IDC_CLASSICSTART_CLEAR:
|
2024-02-27 11:41:43 +00:00
|
|
|
OnClearRecentItems(hwnd);
|
2020-01-31 11:09:00 +00:00
|
|
|
break;
|
2015-11-21 12:49:38 +00:00
|
|
|
case IDOK:
|
2024-02-27 11:41:43 +00:00
|
|
|
if (CustomizeClassic_OnOK(hwnd))
|
|
|
|
EndDialog(hwnd, IDOK);
|
2020-01-31 11:09:00 +00:00
|
|
|
break;
|
2015-11-21 12:49:38 +00:00
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hwnd, IDCANCEL);
|
2020-01-31 11:09:00 +00:00
|
|
|
break;
|
2015-11-21 12:49:38 +00:00
|
|
|
}
|
2020-01-31 11:09:00 +00:00
|
|
|
break;
|
2015-11-21 12:49:38 +00:00
|
|
|
default:
|
2024-03-19 22:32:52 +00:00
|
|
|
break;
|
2015-11-21 12:49:38 +00:00
|
|
|
}
|
2024-03-19 22:32:52 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2015-11-21 12:49:38 +00:00
|
|
|
}
|
2015-12-05 18:29:33 +00:00
|
|
|
|
2015-11-21 12:49:38 +00:00
|
|
|
VOID ShowCustomizeClassic(HINSTANCE hInst, HWND hExplorer)
|
2015-12-05 18:29:33 +00:00
|
|
|
{
|
2016-06-04 14:09:20 +00:00
|
|
|
DialogBoxW(hInst, MAKEINTRESOURCEW(IDD_CLASSICSTART_CUSTOMIZE), hExplorer, CustomizeClassicProc);
|
2015-12-05 18:29:33 +00:00
|
|
|
}
|