ReactOS 0.4.16-dev-1163-gec5b142
startmnucust.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Explorer
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: "Customize Start Menu" dialog
5 * COPYRIGHT: Copyright 2006-2007 Thomas Weidenmueller <w3seek@reactos.org>
6 * Copyright 2015 Robert Naumann <gonzomdx@gmail.com>
7 * Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
8 */
9
10#include "precomp.h"
11
12// TreeView checkbox state indexes (Use with INDEXTOSTATEIMAGEMASK macro)
13#define I_UNCHECKED 1
14#define I_CHECKED 2
15
16// TODO: Windows Explorer appears to be calling NewLinkHere / ConfigStartMenu directly for both items.
18{
20
22 {
23 WCHAR szCommand[MAX_PATH] = L"appwiz.cpl,NewLinkHere ";
24 if (SUCCEEDED(StringCchCatW(szCommand, _countof(szCommand), szPath)))
25 ShellExecuteW(hDlg, L"open", L"rundll32.exe", szCommand, NULL, SW_SHOWNORMAL);
26 }
27}
28
30{
31 ShellExecuteW(hDlg, L"open", L"rundll32.exe", L"appwiz.cpl,ConfigStartMenu", NULL, SW_SHOWNORMAL);
32}
33
35{
37
39 {
41 }
42}
43
45{
48 return FALSE;
49
50 // Find shortcut files in Recent
52 PathAppendW(szPath, L"*.lnk");
54 if (hFind == INVALID_HANDLE_VALUE)
55 return FALSE;
56
57 FindClose(hFind);
58 return TRUE;
59}
60
61static const PCWSTR g_MruKeys[] =
62{
63 L"Software\\Microsoft\\Internet Explorer\\TypedURLs",
64 L"Explorer\\RunMRU",
65 L"Explorer\\Comdlg32\\OpenSaveMRU",
66 L"Explorer\\Comdlg32\\LastVisitedMRU",
67};
68
70{
71 for (UINT i = 0; i < _countof(g_MruKeys); ++i)
72 {
73 WCHAR szKey[200];
74 PCWSTR pszKey = g_MruKeys[i];
75 if (*pszKey != 'S') // Keys not starting with S[oftware] are assumed to be relative to "SMWCV"
76 {
77 wsprintfW(szKey, L"%s\\%s", L"Software\\Microsoft\\Windows\\CurrentVersion", pszKey);
78 pszKey = szKey;
79 }
80
81 HKEY hKey;
82 if (Delete)
83 {
85 }
87 {
89 return TRUE;
90 }
91 }
92 return FALSE;
93}
94
96{
99}
100
102{
105 if (!bHasData && hWndClear == GetFocus())
107 EnableWindow(hWndClear, bHasData);
108}
109
110struct CUSTOM_ENTRY;
111
114
116{
123};
124
126{
127 return GetAdvancedBool(entry->name, entry->bDefaultValue);
128}
129
131{
132 SetAdvancedDword(entry->name, bValue);
133}
134
136{
138}
139
141{
143}
144
146{
147 {
148 IDS_ADVANCED_DISPLAY_ADMINTOOLS, L"StartMenuAdminTools", TRUE,
150 },
151 {
152 IDS_ADVANCED_DISPLAY_FAVORITES, L"StartMenuFavorites", FALSE,
155 },
156 {
157 IDS_ADVANCED_DISPLAY_LOG_OFF, L"StartMenuLogoff", FALSE,
160 },
161 {
162 IDS_ADVANCED_DISPLAY_RUN, L"StartMenuRun", TRUE,
165 },
166 {
167 IDS_ADVANCED_EXPAND_MY_DOCUMENTS, L"CascadeMyDocuments", FALSE,
170 },
171 {
172 IDS_ADVANCED_EXPAND_MY_PICTURES, L"CascadeMyPictures", FALSE,
175 },
176 {
177 IDS_ADVANCED_EXPAND_CONTROL_PANEL, L"CascadeControlPanel", FALSE,
180 },
181 {
182 IDS_ADVANCED_EXPAND_PRINTERS, L"CascadePrinters", FALSE,
185 },
186 {
187 IDS_ADVANCED_EXPAND_NET_CONNECTIONS, L"CascadeNetworkConnections", FALSE,
190 },
191 {
194 },
195};
196
197static VOID AddCustomItem(HWND hTreeView, const CUSTOM_ENTRY *entry)
198{
199 if (SHRestricted(entry->policy1) || SHRestricted(entry->policy2))
200 {
201 TRACE("%p: Restricted\n", entry->id);
202 return; // Restricted. Don't show
203 }
204
205 WCHAR szText[MAX_PATH];
206 LoadStringW(GetModuleHandleW(L"shell32.dll"), entry->id, szText, _countof(szText));
207
208 BOOL bChecked = entry->fnGetValue(entry);
209 TRACE("%p: %d\n", entry->id, bChecked);
210
212 Insert.item.pszText = szText;
213 Insert.item.lParam = entry->id;
214 Insert.item.stateMask = TVIS_STATEIMAGEMASK;
215 Insert.item.state = INDEXTOSTATEIMAGEMASK(bChecked ? I_CHECKED : I_UNCHECKED);
216 TreeView_InsertItem(hTreeView, &Insert);
217}
218
220{
222
224
227
228 for (auto& entry : s_CustomEntries)
229 {
230 AddCustomItem(hTreeView, &entry);
231 }
232}
233
235{
237
238 for (HTREEITEM hItem = TreeView_GetRoot(hTreeView);
239 hItem != NULL;
240 hItem = TreeView_GetNextVisible(hTreeView, hItem))
241 {
243 item.stateMask = TVIS_STATEIMAGEMASK;
244 TreeView_GetItem(hTreeView, &item);
245
246 BOOL bChecked = !!(item.state & INDEXTOSTATEIMAGEMASK(I_CHECKED));
247 for (auto& entry : s_CustomEntries)
248 {
249 if (SHRestricted(entry.policy1) || SHRestricted(entry.policy2))
250 continue;
251
252 if (item.lParam == entry.id)
253 {
254 TRACE("%p: %d\n", item.lParam, bChecked);
255 entry.fnSetValue(&entry, bChecked);
256 break;
257 }
258 }
259 }
260
262 SMTO_ABORTIFHUNG, 200, NULL);
263 return TRUE;
264}
265
267{
268 switch (Message)
269 {
270 case WM_INITDIALOG:
272 return TRUE;
273 case WM_COMMAND:
274 switch (LOWORD(wParam))
275 {
278 break;
281 break;
284 break;
288 break;
289 case IDOK:
292 break;
293 case IDCANCEL:
295 break;
296 }
297 break;
298 default:
299 break;
300 }
301
302 return FALSE;
303}
304
306{
308}
#define VOID
Definition: acefi.h:82
Arabic default style
Definition: afstyles.h:94
BOOL Delete(LPCTSTR ServiceName)
Definition: delete.c:12
BOOL SetAdvancedDword(IN LPCWSTR pszValueName, IN DWORD dwValue)
Definition: util.cpp:161
BOOL GetAdvancedBool(IN LPCWSTR pszValueName, IN BOOL bDefaultValue)
Definition: util.cpp:156
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
#define IDS_ADVANCED_SMALL_START_MENU
Definition: resource.h:126
#define IDS_ADVANCED_EXPAND_CONTROL_PANEL
Definition: resource.h:119
#define IDS_ADVANCED_DISPLAY_ADMINTOOLS
Definition: resource.h:125
#define IDC_CLASSICSTART_ADVANCED
Definition: resource.h:171
#define IDS_ADVANCED_DISPLAY_RUN
Definition: resource.h:124
#define IDC_CLASSICSTART_REMOVE
Definition: resource.h:170
#define IDS_ADVANCED_EXPAND_NET_CONNECTIONS
Definition: resource.h:123
#define IDC_CLASSICSTART_CLEAR
Definition: resource.h:173
#define IDS_ADVANCED_DISPLAY_FAVORITES
Definition: resource.h:117
#define IDS_ADVANCED_EXPAND_MY_PICTURES
Definition: resource.h:122
#define IDS_ADVANCED_EXPAND_MY_DOCUMENTS
Definition: resource.h:120
#define IDC_CLASSICSTART_ADD
Definition: resource.h:169
#define IDD_CLASSICSTART_CUSTOMIZE
Definition: resource.h:93
#define IDS_ADVANCED_DISPLAY_LOG_OFF
Definition: resource.h:118
#define IDS_ADVANCED_EXPAND_PRINTERS
Definition: resource.h:121
#define IDC_CLASSICSTART_SETTINGS
Definition: resource.h:174
#define RegCloseKey(hKey)
Definition: registry.h:49
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static TAGID TAGID find
Definition: db.cpp:155
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2716
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1546
static const WCHAR Message[]
Definition: register.c:74
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
FxAutoRegKey hKey
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
uint32_t entry
Definition: isohybrid.c:63
LPCWSTR szPath
Definition: env.c:37
static ATOM item
Definition: dde.c:856
unsigned int UINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
#define KEY_WRITE
Definition: nt_native.h:1031
#define L(x)
Definition: ntvdm.h:50
#define PathAppendW
Definition: pathcch.h:309
#define LOWORD(l)
Definition: pedump.c:82
#define TVI_LAST
Definition: commctrl.h:3375
#define TVIF_TEXT
Definition: commctrl.h:3271
#define TreeView_GetNextVisible(hwnd, hitem)
Definition: commctrl.h:3476
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3495
#define TV_INSERTSTRUCT
Definition: commctrl.h:3382
#define TVI_ROOT
Definition: commctrl.h:3373
#define TVS_CHECKBOXES
Definition: commctrl.h:3260
#define TV_ITEM
Definition: commctrl.h:3305
#define TreeView_GetRoot(hwnd)
Definition: commctrl.h:3480
#define TVIS_STATEIMAGEMASK
Definition: commctrl.h:3293
#define INDEXTOSTATEIMAGEMASK(i)
Definition: commctrl.h:2333
#define TVIF_PARAM
Definition: commctrl.h:3273
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3417
#define TVIF_STATE
Definition: commctrl.h:3274
#define CSIDL_FLAG_CREATE
void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv)
Definition: shellord.c:1011
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2529
#define CSIDL_RECENT
Definition: shlobj.h:2189
#define SHARD_PIDL
Definition: shlobj.h:1182
#define CSIDL_STARTMENU
Definition: shlobj.h:2192
#define CSIDL_PROGRAMS
Definition: shlobj.h:2183
RESTRICTIONS
Definition: shlobj.h:1649
@ REST_NOSETFOLDERS
Definition: shlobj.h:1655
@ REST_NOCONTROLPANEL
Definition: shlobj.h:1716
@ REST_NOSMMYPICS
Definition: shlobj.h:1766
@ REST_STARTMENULOGOFF
Definition: shlobj.h:1679
@ REST_NONETWORKCONNECTIONS
Definition: shlobj.h:1726
@ REST_NOSMMYDOCS
Definition: shlobj.h:1764
@ REST_NORUN
Definition: shlobj.h:1651
@ REST_NOFAVORITESMENU
Definition: shlobj.h:1686
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:166
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL CALLBACK CustomGetAdvanced(const CUSTOM_ENTRY *entry)
VOID OnRemoveStartmenuItems(HWND hDlg)
VOID(CALLBACK * FN_CUSTOM_SET)(const CUSTOM_ENTRY *entry, BOOL bValue)
static const CUSTOM_ENTRY s_CustomEntries[]
static VOID InitializeClearButton(HWND hwnd)
BOOL(CALLBACK * FN_CUSTOM_GET)(const CUSTOM_ENTRY *entry)
static BOOL CALLBACK CustomGetSmallStartMenu(const CUSTOM_ENTRY *entry)
static VOID AddCustomItem(HWND hTreeView, const CUSTOM_ENTRY *entry)
static BOOL RecentHasShortcut(HWND hwnd)
static VOID CALLBACK CustomSetSmallStartMenu(const CUSTOM_ENTRY *entry, BOOL bValue)
#define I_UNCHECKED
VOID OnAdvancedStartMenuItems()
static BOOL CustomizeClassic_OnOK(HWND hwnd)
VOID ShowCustomizeClassic(HINSTANCE hInst, HWND hExplorer)
static void CustomizeClassic_OnInitDialog(HWND hwnd)
static VOID CALLBACK CustomSetAdvanced(const CUSTOM_ENTRY *entry, BOOL bValue)
static const PCWSTR g_MruKeys[]
INT_PTR CALLBACK CustomizeClassicProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
#define I_CHECKED
VOID ClearRecentAndMru()
static BOOL HandleMruData(BOOL Delete)
VOID OnAddStartMenuItems(HWND hDlg)
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
BOOL bDefaultValue
LPARAM id
RESTRICTIONS policy1
FN_CUSTOM_SET fnSetValue
FN_CUSTOM_GET fnGetValue
RESTRICTIONS policy2
LPCWSTR name
TW_STRUCKRECTS2 sr
Definition: precomp.h:226
DWORD SmSmallIcons
Definition: precomp.h:207
int32_t INT_PTR
Definition: typedefs.h:64
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint32_t DWORD_PTR
Definition: typedefs.h:65
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define SW_SHOWNORMAL
Definition: winuser.h:781
HWND WINAPI GetFocus(void)
Definition: window.c:1863
#define GetWindowLongPtrW
Definition: winuser.h:4840
#define IDCANCEL
Definition: winuser.h:842
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4410
#define HWND_BROADCAST
Definition: winuser.h:1215
#define WM_COMMAND
Definition: winuser.h:1751
#define WM_INITDIALOG
Definition: winuser.h:1750
LRESULT WINAPI SendMessageTimeoutW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM, _In_ UINT, _In_ UINT, _Out_opt_ PDWORD_PTR)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:841
#define WM_NEXTDLGCTL
Definition: winuser.h:1654
#define WM_SETTINGCHANGE
Definition: winuser.h:1640
#define SendMessage
Definition: winuser.h:5863
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1234
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SetWindowLongPtrW
Definition: winuser.h:5366
#define GWL_STYLE
Definition: winuser.h:863
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185