ReactOS 0.4.16-dev-1188-gc03d779
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 BOOL HandleMruData (BOOL Delete)
 
VOID ClearRecentAndMru ()
 
static VOID InitializeClearButton (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 PCWSTR g_MruKeys []
 
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 112 of file startmnucust.cpp.

◆ FN_CUSTOM_SET

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

Definition at line 113 of file startmnucust.cpp.

Function Documentation

◆ AddCustomItem()

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

Definition at line 197 of file startmnucust.cpp.

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}
#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:3375
#define TVIF_TEXT
Definition: commctrl.h:3271
#define TV_INSERTSTRUCT
Definition: commctrl.h:3382
#define TVI_ROOT
Definition: commctrl.h:3373
#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
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:166
#define _countof(array)
Definition: sndvol32.h:70
#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().

◆ ClearRecentAndMru()

VOID ClearRecentAndMru ( )

Definition at line 95 of file startmnucust.cpp.

96{
99}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv)
Definition: shellord.c:1011
#define SHARD_PIDL
Definition: shlobj.h:1182
static BOOL HandleMruData(BOOL Delete)

Referenced by CustomizeClassicProc(), and CTrayWindow::SaveState().

◆ CustomGetAdvanced()

static BOOL CALLBACK CustomGetAdvanced ( const CUSTOM_ENTRY entry)
static

Definition at line 125 of file startmnucust.cpp.

126{
127 return GetAdvancedBool(entry->name, entry->bDefaultValue);
128}
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 135 of file startmnucust.cpp.

136{
138}
TaskbarSettings g_TaskbarSettings
Definition: settings.cpp:23
TW_STRUCKRECTS2 sr
Definition: precomp.h:226
DWORD SmSmallIcons
Definition: precomp.h:207

◆ CustomizeClassic_OnInitDialog()

static void CustomizeClassic_OnInitDialog ( HWND  hwnd)
static

Definition at line 219 of file startmnucust.cpp.

220{
222
224
227
228 for (auto& entry : s_CustomEntries)
229 {
230 AddCustomItem(hTreeView, &entry);
231 }
232}
Arabic default style
Definition: afstyles.h:94
#define IDC_CLASSICSTART_SETTINGS
Definition: resource.h:174
#define TVS_CHECKBOXES
Definition: commctrl.h:3260
static const CUSTOM_ENTRY s_CustomEntries[]
static VOID InitializeClearButton(HWND hwnd)
static VOID AddCustomItem(HWND hTreeView, const CUSTOM_ENTRY *entry)
uint32_t DWORD_PTR
Definition: typedefs.h:65
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define GetWindowLongPtrW
Definition: winuser.h:4848
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SetWindowLongPtrW
Definition: winuser.h:5374
#define GWL_STYLE
Definition: winuser.h:863

Referenced by CustomizeClassicProc().

◆ CustomizeClassic_OnOK()

static BOOL CustomizeClassic_OnOK ( HWND  hwnd)
static

Definition at line 234 of file startmnucust.cpp.

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}
static ATOM item
Definition: dde.c:856
#define TreeView_GetNextVisible(hwnd, hitem)
Definition: commctrl.h:3476
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3495
#define TV_ITEM
Definition: commctrl.h:3305
#define TreeView_GetRoot(hwnd)
Definition: commctrl.h:3480
LONG_PTR LPARAM
Definition: windef.h:208
#define HWND_BROADCAST
Definition: winuser.h:1215
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:1648
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1234

Referenced by CustomizeClassicProc().

◆ CustomizeClassicProc()

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

Definition at line 266 of file startmnucust.cpp.

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}
#define IDC_CLASSICSTART_ADVANCED
Definition: resource.h:171
#define IDC_CLASSICSTART_REMOVE
Definition: resource.h:170
#define IDC_CLASSICSTART_CLEAR
Definition: resource.h:173
#define IDC_CLASSICSTART_ADD
Definition: resource.h:169
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)
VOID ClearRecentAndMru()
VOID OnAddStartMenuItems(HWND hDlg)
#define IDCANCEL
Definition: winuser.h:842
#define WM_COMMAND
Definition: winuser.h:1759
#define WM_INITDIALOG
Definition: winuser.h:1758
#define IDOK
Definition: winuser.h:841
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 130 of file startmnucust.cpp.

131{
132 SetAdvancedDword(entry->name, bValue);
133}
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 140 of file startmnucust.cpp.

141{
143}

◆ HandleMruData()

static BOOL HandleMruData ( BOOL  Delete)
static

Definition at line 69 of file startmnucust.cpp.

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}
BOOL Delete(LPCTSTR ServiceName)
Definition: delete.c:12
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1546
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
unsigned int UINT
Definition: ndis.h:50
#define KEY_WRITE
Definition: nt_native.h:1031
static const PCWSTR g_MruKeys[]
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define HKEY_CURRENT_USER
Definition: winreg.h:11
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)

Referenced by ClearRecentAndMru(), and InitializeClearButton().

◆ InitializeClearButton()

static VOID InitializeClearButton ( HWND  hwnd)
static

Definition at line 101 of file startmnucust.cpp.

102{
105 if (!bHasData && hWndClear == GetFocus())
107 EnableWindow(hWndClear, bHasData);
108}
static BOOL RecentHasShortcut(HWND hwnd)
HWND WINAPI GetFocus(void)
Definition: window.c:1863
#define WM_NEXTDLGCTL
Definition: winuser.h:1662
#define SendMessage
Definition: winuser.h:5871
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by CustomizeClassic_OnInitDialog(), and CustomizeClassicProc().

◆ 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:2716
#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:2529
#define CSIDL_PROGRAMS
Definition: shlobj.h:2183
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
#define SW_SHOWNORMAL
Definition: winuser.h:781

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:2192

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:2189

Referenced by InitializeClearButton().

◆ ShowCustomizeClassic()

VOID ShowCustomizeClassic ( HINSTANCE  hInst,
HWND  hExplorer 
)

Definition at line 305 of file startmnucust.cpp.

306{
308}
#define IDD_CLASSICSTART_CUSTOMIZE
Definition: resource.h:93
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:4418
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by CStartMenuSettingsPage::OnStartMenuCustomize().

Variable Documentation

◆ g_MruKeys

const PCWSTR g_MruKeys[]
static
Initial value:
=
{
L"Software\\Microsoft\\Internet Explorer\\TypedURLs",
L"Explorer\\RunMRU",
L"Explorer\\Comdlg32\\OpenSaveMRU",
L"Explorer\\Comdlg32\\LastVisitedMRU",
}

Definition at line 61 of file startmnucust.cpp.

Referenced by HandleMruData().

◆ s_CustomEntries

const CUSTOM_ENTRY s_CustomEntries[]
static

Definition at line 145 of file startmnucust.cpp.

Referenced by CustomizeClassic_OnInitDialog(), and CustomizeClassic_OnOK().