ReactOS 0.4.16-dev-197-g92996da
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
62{
65}
66
67struct CUSTOM_ENTRY;
68
70typedef VOID (CALLBACK *FN_CUSTOM_SET)(const CUSTOM_ENTRY *entry, BOOL bValue);
71
73{
80};
81
83{
84 return GetAdvancedBool(entry->name, entry->bDefaultValue);
85}
86
88{
89 SetAdvancedDword(entry->name, bValue);
90}
91
93{
95}
96
98{
100}
101
103{
104 {
105 IDS_ADVANCED_DISPLAY_ADMINTOOLS, L"StartMenuAdminTools", TRUE,
107 },
108 {
109 IDS_ADVANCED_DISPLAY_FAVORITES, L"StartMenuFavorites", FALSE,
112 },
113 {
114 IDS_ADVANCED_DISPLAY_LOG_OFF, L"StartMenuLogoff", FALSE,
117 },
118 {
119 IDS_ADVANCED_DISPLAY_RUN, L"StartMenuRun", TRUE,
122 },
123 {
124 IDS_ADVANCED_EXPAND_MY_DOCUMENTS, L"CascadeMyDocuments", FALSE,
127 },
128 {
129 IDS_ADVANCED_EXPAND_MY_PICTURES, L"CascadeMyPictures", FALSE,
132 },
133 {
134 IDS_ADVANCED_EXPAND_CONTROL_PANEL, L"CascadeControlPanel", FALSE,
137 },
138 {
139 IDS_ADVANCED_EXPAND_PRINTERS, L"CascadePrinters", FALSE,
142 },
143 {
144 IDS_ADVANCED_EXPAND_NET_CONNECTIONS, L"CascadeNetworkConnections", FALSE,
147 },
148 {
151 },
152};
153
154static VOID AddCustomItem(HWND hTreeView, const CUSTOM_ENTRY *entry)
155{
156 if (SHRestricted(entry->policy1) || SHRestricted(entry->policy2))
157 {
158 TRACE("%p: Restricted\n", entry->id);
159 return; // Restricted. Don't show
160 }
161
162 WCHAR szText[MAX_PATH];
163 LoadStringW(GetModuleHandleW(L"shell32.dll"), entry->id, szText, _countof(szText));
164
165 BOOL bChecked = entry->fnGetValue(entry);
166 TRACE("%p: %d\n", entry->id, bChecked);
167
169 Insert.item.pszText = szText;
170 Insert.item.lParam = entry->id;
171 Insert.item.stateMask = TVIS_STATEIMAGEMASK;
172 Insert.item.state = INDEXTOSTATEIMAGEMASK(bChecked ? I_CHECKED : I_UNCHECKED);
173 TreeView_InsertItem(hTreeView, &Insert);
174}
175
177{
179
181
184
185 for (auto& entry : s_CustomEntries)
186 {
187 AddCustomItem(hTreeView, &entry);
188 }
189}
190
192{
194
195 for (HTREEITEM hItem = TreeView_GetRoot(hTreeView);
196 hItem != NULL;
197 hItem = TreeView_GetNextVisible(hTreeView, hItem))
198 {
200 item.stateMask = TVIS_STATEIMAGEMASK;
201 TreeView_GetItem(hTreeView, &item);
202
203 BOOL bChecked = !!(item.state & INDEXTOSTATEIMAGEMASK(I_CHECKED));
204 for (auto& entry : s_CustomEntries)
205 {
206 if (SHRestricted(entry.policy1) || SHRestricted(entry.policy2))
207 continue;
208
209 if (item.lParam == entry.id)
210 {
211 TRACE("%p: %d\n", item.lParam, bChecked);
212 entry.fnSetValue(&entry, bChecked);
213 break;
214 }
215 }
216 }
217
219 SMTO_ABORTIFHUNG, 200, NULL);
220 return TRUE;
221}
222
224{
225 switch (Message)
226 {
227 case WM_INITDIALOG:
229 return TRUE;
230 case WM_COMMAND:
231 switch (LOWORD(wParam))
232 {
235 break;
238 break;
241 break;
244 break;
245 case IDOK:
248 break;
249 case IDCANCEL:
251 break;
252 }
253 break;
254 default:
255 break;
256 }
257
258 return FALSE;
259}
260
262{
264}
#define VOID
Definition: acefi.h:82
Arabic default style
Definition: afstyles.h:94
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:119
#define IDS_ADVANCED_EXPAND_CONTROL_PANEL
Definition: resource.h:112
#define IDS_ADVANCED_DISPLAY_ADMINTOOLS
Definition: resource.h:118
#define IDC_CLASSICSTART_ADVANCED
Definition: resource.h:164
#define IDS_ADVANCED_DISPLAY_RUN
Definition: resource.h:117
#define IDC_CLASSICSTART_REMOVE
Definition: resource.h:163
#define IDS_ADVANCED_EXPAND_NET_CONNECTIONS
Definition: resource.h:116
#define IDC_CLASSICSTART_CLEAR
Definition: resource.h:166
#define IDS_ADVANCED_DISPLAY_FAVORITES
Definition: resource.h:110
#define IDS_ADVANCED_EXPAND_MY_PICTURES
Definition: resource.h:115
#define IDS_ADVANCED_EXPAND_MY_DOCUMENTS
Definition: resource.h:113
#define IDC_CLASSICSTART_ADD
Definition: resource.h:162
#define IDD_CLASSICSTART_CUSTOMIZE
Definition: resource.h:87
#define IDS_ADVANCED_DISPLAY_LOG_OFF
Definition: resource.h:111
#define IDS_ADVANCED_EXPAND_PRINTERS
Definition: resource.h:114
#define IDC_CLASSICSTART_SETTINGS
Definition: resource.h:167
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static TAGID TAGID find
Definition: db.cpp:155
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#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:2589
static const WCHAR Message[]
Definition: register.c:74
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
#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 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:1005
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2492
#define CSIDL_RECENT
Definition: shlobj.h:2181
#define SHARD_PIDL
Definition: shlobj.h:1174
#define CSIDL_STARTMENU
Definition: shlobj.h:2184
#define CSIDL_PROGRAMS
Definition: shlobj.h:2175
RESTRICTIONS
Definition: shlobj.h:1641
@ REST_NOSETFOLDERS
Definition: shlobj.h:1647
@ REST_NOCONTROLPANEL
Definition: shlobj.h:1708
@ REST_NOSMMYPICS
Definition: shlobj.h:1758
@ REST_STARTMENULOGOFF
Definition: shlobj.h:1671
@ REST_NONETWORKCONNECTIONS
Definition: shlobj.h:1718
@ REST_NOSMMYDOCS
Definition: shlobj.h:1756
@ REST_NORUN
Definition: shlobj.h:1643
@ REST_NOFAVORITESMENU
Definition: shlobj.h:1678
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:150
#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[]
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)
INT_PTR CALLBACK CustomizeClassicProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
#define I_CHECKED
static VOID OnClearRecentItems(HWND hwnd)
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:225
DWORD SmSmallIcons
Definition: precomp.h:206
int32_t INT_PTR
Definition: typedefs.h:64
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 SW_SHOWNORMAL
Definition: winuser.h:773
#define GetWindowLongPtrW
Definition: winuser.h:4832
#define IDCANCEL
Definition: winuser.h:834
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4402
#define HWND_BROADCAST
Definition: winuser.h:1207
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
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:833
#define WM_SETTINGCHANGE
Definition: winuser.h:1632
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1226
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SetWindowLongPtrW
Definition: winuser.h:5358
#define GWL_STYLE
Definition: winuser.h:855
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185