ReactOS 0.4.15-dev-7842-g558ab78
startmnucust.cpp File Reference
#include "precomp.h"
Include dependency graph for startmnucust.cpp:

Go to the source code of this file.

Classes

struct  CUSTOM_ENTRY
 

Macros

#define I_UNCHECKED   1
 
#define I_CHECKED   2
 

Typedefs

typedef BOOL(CALLBACKFN_CUSTOM_GET) (const CUSTOM_ENTRY *entry)
 
typedef VOID(CALLBACKFN_CUSTOM_SET) (const CUSTOM_ENTRY *entry, BOOL bValue)
 

Functions

VOID OnAddStartMenuItems (HWND hDlg)
 
VOID OnRemoveStartmenuItems (HWND hDlg)
 
VOID OnAdvancedStartMenuItems ()
 
static BOOL RecentHasShortcut (HWND hwnd)
 
static VOID OnClearRecentItems (HWND hwnd)
 
static BOOL CALLBACK CustomGetAdvanced (const CUSTOM_ENTRY *entry)
 
static VOID CALLBACK CustomSetAdvanced (const CUSTOM_ENTRY *entry, BOOL bValue)
 
static BOOL CALLBACK CustomGetSmallStartMenu (const CUSTOM_ENTRY *entry)
 
static VOID CALLBACK CustomSetSmallStartMenu (const CUSTOM_ENTRY *entry, BOOL bValue)
 
static VOID AddCustomItem (HWND hTreeView, const CUSTOM_ENTRY *entry)
 
static void CustomizeClassic_OnInitDialog (HWND hwnd)
 
static BOOL CustomizeClassic_OnOK (HWND hwnd)
 
INT_PTR CALLBACK CustomizeClassicProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
 
VOID ShowCustomizeClassic (HINSTANCE hInst, HWND hExplorer)
 

Variables

static const CUSTOM_ENTRY s_CustomEntries []
 

Macro Definition Documentation

◆ I_CHECKED

#define I_CHECKED   2

Definition at line 14 of file startmnucust.cpp.

◆ I_UNCHECKED

#define I_UNCHECKED   1

Definition at line 13 of file startmnucust.cpp.

Typedef Documentation

◆ FN_CUSTOM_GET

typedef BOOL(CALLBACK * FN_CUSTOM_GET) (const CUSTOM_ENTRY *entry)

Definition at line 69 of file startmnucust.cpp.

◆ FN_CUSTOM_SET

typedef VOID(CALLBACK * FN_CUSTOM_SET) (const CUSTOM_ENTRY *entry, BOOL bValue)

Definition at line 70 of file startmnucust.cpp.

Function Documentation

◆ AddCustomItem()

static VOID AddCustomItem ( HWND  hTreeView,
const CUSTOM_ENTRY entry 
)
static

Definition at line 154 of file startmnucust.cpp.

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}
#define MAX_PATH
Definition: compat.h:34
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
unsigned int BOOL
Definition: ntddk_ex.h:94
uint32_t entry
Definition: isohybrid.c:63
#define L(x)
Definition: ntvdm.h:50
#define TVI_LAST
Definition: commctrl.h:3370
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TV_INSERTSTRUCT
Definition: commctrl.h:3377
#define TVI_ROOT
Definition: commctrl.h:3368
#define TVIS_STATEIMAGEMASK
Definition: commctrl.h:3288
#define INDEXTOSTATEIMAGEMASK(i)
Definition: commctrl.h:2328
#define TVIF_PARAM
Definition: commctrl.h:3268
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3412
#define TVIF_STATE
Definition: commctrl.h:3269
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:146
#define _countof(array)
Definition: sndvol32.h:68
#define TRACE(s)
Definition: solgame.cpp:4
#define I_UNCHECKED
#define I_CHECKED
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CustomizeClassic_OnInitDialog().

◆ CustomGetAdvanced()

static BOOL CALLBACK CustomGetAdvanced ( const CUSTOM_ENTRY entry)
static

Definition at line 82 of file startmnucust.cpp.

83{
84 return GetAdvancedBool(entry->name, entry->bDefaultValue);
85}
BOOL GetAdvancedBool(IN LPCWSTR pszValueName, IN BOOL bDefaultValue)
Definition: util.cpp:156

◆ CustomGetSmallStartMenu()

static BOOL CALLBACK CustomGetSmallStartMenu ( const CUSTOM_ENTRY entry)
static

Definition at line 92 of file startmnucust.cpp.

93{
95}
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
TW_STRUCKRECTS2 sr
Definition: precomp.h:225
DWORD SmSmallIcons
Definition: precomp.h:206

◆ CustomizeClassic_OnInitDialog()

static void CustomizeClassic_OnInitDialog ( HWND  hwnd)
static

Definition at line 176 of file startmnucust.cpp.

177{
179
181
184
185 for (auto& entry : s_CustomEntries)
186 {
187 AddCustomItem(hTreeView, &entry);
188 }
189}
Arabic default style
Definition: afstyles.h:94
#define IDC_CLASSICSTART_CLEAR
Definition: resource.h:166
#define IDC_CLASSICSTART_SETTINGS
Definition: resource.h:167
#define TVS_CHECKBOXES
Definition: commctrl.h:3255
static const CUSTOM_ENTRY s_CustomEntries[]
static VOID AddCustomItem(HWND hTreeView, const CUSTOM_ENTRY *entry)
static BOOL RecentHasShortcut(HWND hwnd)
uint32_t DWORD_PTR
Definition: typedefs.h:65
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define GetWindowLongPtrW
Definition: winuser.h:4829
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SetWindowLongPtrW
Definition: winuser.h:5346
#define GWL_STYLE
Definition: winuser.h:852

Referenced by CustomizeClassicProc().

◆ CustomizeClassic_OnOK()

static BOOL CustomizeClassic_OnOK ( HWND  hwnd)
static

Definition at line 191 of file startmnucust.cpp.

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}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
static ATOM item
Definition: dde.c:856
#define TreeView_GetNextVisible(hwnd, hitem)
Definition: commctrl.h:3471
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490
#define TV_ITEM
Definition: commctrl.h:3300
#define TreeView_GetRoot(hwnd)
Definition: commctrl.h:3475
LONG_PTR LPARAM
Definition: windef.h:208
#define HWND_BROADCAST
Definition: winuser.h:1204
LRESULT WINAPI SendMessageTimeoutW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM, _In_ UINT, _In_ UINT, _Out_opt_ PDWORD_PTR)
#define WM_SETTINGCHANGE
Definition: winuser.h:1629
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1223

Referenced by CustomizeClassicProc().

◆ CustomizeClassicProc()

INT_PTR CALLBACK CustomizeClassicProc ( HWND  hwnd,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 223 of file startmnucust.cpp.

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}
#define IDC_CLASSICSTART_ADVANCED
Definition: resource.h:164
#define IDC_CLASSICSTART_REMOVE
Definition: resource.h:163
#define IDC_CLASSICSTART_ADD
Definition: resource.h:162
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
static const WCHAR Message[]
Definition: register.c:74
#define LOWORD(l)
Definition: pedump.c:82
VOID OnRemoveStartmenuItems(HWND hDlg)
VOID OnAdvancedStartMenuItems()
static BOOL CustomizeClassic_OnOK(HWND hwnd)
static void CustomizeClassic_OnInitDialog(HWND hwnd)
static VOID OnClearRecentItems(HWND hwnd)
VOID OnAddStartMenuItems(HWND hDlg)
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define IDOK
Definition: winuser.h:830
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by ShowCustomizeClassic().

◆ CustomSetAdvanced()

static VOID CALLBACK CustomSetAdvanced ( const CUSTOM_ENTRY entry,
BOOL  bValue 
)
static

Definition at line 87 of file startmnucust.cpp.

88{
89 SetAdvancedDword(entry->name, bValue);
90}
BOOL SetAdvancedDword(IN LPCWSTR pszValueName, IN DWORD dwValue)
Definition: util.cpp:161

◆ CustomSetSmallStartMenu()

static VOID CALLBACK CustomSetSmallStartMenu ( const CUSTOM_ENTRY entry,
BOOL  bValue 
)
static

Definition at line 97 of file startmnucust.cpp.

98{
100}

◆ OnAddStartMenuItems()

VOID OnAddStartMenuItems ( HWND  hDlg)

Definition at line 17 of file startmnucust.cpp.

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}
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2558
#define SUCCEEDED(hr)
Definition: intsafe.h:50
LPCWSTR szPath
Definition: env.c:37
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2402
#define CSIDL_PROGRAMS
Definition: shlobj.h:2160
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
#define SW_SHOWNORMAL
Definition: winuser.h:770

Referenced by CustomizeClassicProc().

◆ OnAdvancedStartMenuItems()

VOID OnAdvancedStartMenuItems ( )

Definition at line 34 of file startmnucust.cpp.

35{
37
39 {
41 }
42}
#define CSIDL_STARTMENU
Definition: shlobj.h:2169

Referenced by CustomizeClassicProc().

◆ OnClearRecentItems()

static VOID OnClearRecentItems ( HWND  hwnd)
static

Definition at line 61 of file startmnucust.cpp.

62{
65}
void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv)
Definition: shellord.c:813
#define SHARD_PIDL
Definition: shlobj.h:1167

Referenced by CustomizeClassicProc().

◆ OnRemoveStartmenuItems()

VOID OnRemoveStartmenuItems ( HWND  hDlg)

Definition at line 29 of file startmnucust.cpp.

30{
31 ShellExecuteW(hDlg, L"open", L"rundll32.exe", L"appwiz.cpl,ConfigStartMenu", NULL, SW_SHOWNORMAL);
32}

Referenced by CustomizeClassicProc().

◆ RecentHasShortcut()

static BOOL RecentHasShortcut ( HWND  hwnd)
static

Definition at line 44 of file startmnucust.cpp.

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}
static TAGID TAGID find
Definition: db.cpp:155
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
#define FAILED(hr)
Definition: intsafe.h:51
#define PathAppendW
Definition: pathcch.h:309
#define CSIDL_FLAG_CREATE
#define CSIDL_RECENT
Definition: shlobj.h:2166

Referenced by CustomizeClassic_OnInitDialog(), and OnClearRecentItems().

◆ ShowCustomizeClassic()

VOID ShowCustomizeClassic ( HINSTANCE  hInst,
HWND  hExplorer 
)

Definition at line 261 of file startmnucust.cpp.

262{
264}
#define IDD_CLASSICSTART_CUSTOMIZE
Definition: resource.h:87
HINSTANCE hInst
Definition: dxdiag.c:13
INT_PTR CALLBACK CustomizeClassicProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4399
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by CStartMenuSettingsPage::OnStartMenuCustomize().

Variable Documentation

◆ s_CustomEntries

const CUSTOM_ENTRY s_CustomEntries[]
static

Definition at line 102 of file startmnucust.cpp.

Referenced by CustomizeClassic_OnInitDialog(), and CustomizeClassic_OnOK().