ReactOS 0.4.16-dev-1541-g7e1d9ef
performance.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS System Control Panel Applet
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * FILE: dll/cpl/sysdm/performance.c
5 * PURPOSE: Performance settings property sheets
6 * COPYRIGHT: Copyright 2024 Whindmar Saksit <whindsaks@proton.me>
7 *
8 */
9
10#include "precomp.h"
11#include <shlguid_undoc.h> // CLSID_CRegTreeOptions
12#include <shlobj_undoc.h> // IRegTreeOptions
13
14static VOID
15RegTreeOpt_OnDestroy(IRegTreeOptions *pRTO)
16{
17 if (pRTO)
18 {
19 IRegTreeOptions_WalkTree(pRTO, WALK_TREE_DESTROY);
20 IRegTreeOptions_Release(pRTO);
21 }
22}
23
24static BOOL
26{
27 return pRTO && SUCCEEDED(IRegTreeOptions_ToggleItem(pRTO, hItem));
28}
29
30static BOOL
31RegTreeOpt_OnTreeViewClick(IRegTreeOptions *pRTO, HWND hWndTree)
32{
33 TV_HITTESTINFO HitTest;
34 DWORD dwPos = GetMessagePos();
35 HitTest.pt.x = GET_X_LPARAM(dwPos);
36 HitTest.pt.y = GET_Y_LPARAM(dwPos);
37 ScreenToClient(hWndTree, &HitTest.pt);
38 HTREEITEM hItem = TreeView_HitTest(hWndTree, &HitTest);
40}
41
42static BOOL
43RegTreeOpt_OnTreeViewKeyDown(IRegTreeOptions *pRTO, HWND hWndTree, TV_KEYDOWN *pKey)
44{
45 if (pKey->wVKey == VK_SPACE)
47 else if (pKey->wVKey == VK_F5 && pRTO)
48 IRegTreeOptions_WalkTree(pRTO, WALK_TREE_REFRESH);
49 return FALSE;
50}
51
52static INT_PTR CALLBACK
54{
55 IRegTreeOptions *pRTO = (IRegTreeOptions*)GetWindowLongPtrW(hDlg, DWLP_USER);
56 HWND hWndTree = GetDlgItem(hDlg, IDC_TREE);
57
58 switch (uMsg)
59 {
60 case WM_INITDIALOG:
61 {
62 IRegTreeOptions *pRTO = NULL;
63 if (SUCCEEDED(CoCreateInstance(&CLSID_CRegTreeOptions, NULL, CLSCTX_INPROC_SERVER,
64 &IID_IRegTreeOptions, (void**)&pRTO)))
65 {
66 LPCSTR pszPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VisualEffects";
68 IRegTreeOptions_InitTree(pRTO, hWndTree, HKEY_LOCAL_MACHINE, pszPath, NULL);
69 }
70 else
71 {
72 // Without IRegTreeOptions, our page is pointless so we remove it.
73 // MSDN says we have to post the remove message from inside WM_INITDIALOG.
74 HWND hWndPS = GetParent(hDlg);
75 int iPage = PropSheet_HwndToIndex(hWndPS, hDlg);
76 PostMessage(hWndPS, PSM_REMOVEPAGE, 0, SendMessageW(hWndPS, PSM_INDEXTOPAGE, iPage, 0));
77 }
78 return TRUE;
79 }
80
81 case WM_DESTROY:
84 break;
85
86 case WM_NOTIFY:
87 switch (((LPNMHDR)lParam)->code)
88 {
89 case NM_CLICK:
90 if (RegTreeOpt_OnTreeViewClick(pRTO, hWndTree))
91 PropSheet_Changed(GetParent(hDlg), hDlg);
92 break;
93
94 case TVN_KEYDOWN:
95 if (RegTreeOpt_OnTreeViewKeyDown(pRTO, hWndTree, (TV_KEYDOWN*)lParam))
96 PropSheet_Changed(GetParent(hDlg), hDlg);
97 break;
98
99 case PSN_APPLY:
100 {
101 if (pRTO)
102 IRegTreeOptions_WalkTree(pRTO, WALK_TREE_SAVE);
103
104 SHSendMessageBroadcastW(WM_SETTINGCHANGE, 0, 0); // For the ListviewShadow setting
105 return TRUE;
106 }
107 }
108 break;
109 }
110 return FALSE;
111}
112
113static INT_PTR CALLBACK
115{
116 switch (uMsg)
117 {
118 case WM_INITDIALOG:
119 // TODO: Not implemented yet
122 return TRUE;
123
124 case WM_COMMAND:
125 switch (LOWORD(wParam))
126 {
127 case IDC_CHANGESWAP:
129 break;
130 }
131 break;
132 }
133 return FALSE;
134}
135
136VOID
138{
139 HRESULT hrInit = CoInitialize(NULL); // For IRegTreeOptions
140 PROPSHEETHEADERW psh = { sizeof(psh), PSH_PROPSHEETPAGE | PSH_NOCONTEXTHELP };
141 PROPSHEETPAGEW pages[2] = { 0 };
142
143 pages[0].dwSize = sizeof(*pages);
144 pages[0].hInstance = hApplet;
147
148 pages[1].dwSize = sizeof(*pages);
149 pages[1].hInstance = hApplet;
151 pages[1].pfnDlgProc = AdvancedDlgProc;
152
153 psh.hwndParent = hDlg;
154 psh.hInstance = hApplet;
156 psh.nPages = _countof(pages);
157 psh.ppsp = pages;
158
159 PropertySheetW(&psh);
160
161 if (SUCCEEDED(hrInit))
163}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HINSTANCE hApplet
Definition: access.c:17
INT_PTR CALLBACK VirtMemDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: virtmem.c:821
#define IDC_CPUCLIENT
Definition: resource.h:163
#define IDC_CPUSERVER
Definition: resource.h:164
#define IDS_PERFORMANCEOPTIONS
Definition: resource.h:17
#define IDD_VIRTMEM
Definition: resource.h:168
#define IDC_CHANGESWAP
Definition: resource.h:165
#define IDD_VISUALEFFECTS
Definition: resource.h:158
#define IDC_TREE
Definition: resource.h:159
#define IDD_ADVANCEDPERF
Definition: resource.h:162
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2916
#define CALLBACK
Definition: compat.h:35
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
DWORD WINAPI SHSendMessageBroadcastW(UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ordinal.c:4191
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxRegKey * pKey
#define SUCCEEDED(hr)
Definition: intsafe.h:50
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
static INT_PTR CALLBACK VisualEffectsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: performance.c:53
static BOOL RegTreeOpt_ToggleCheckItem(IRegTreeOptions *pRTO, HTREEITEM hItem)
Definition: performance.c:25
static BOOL RegTreeOpt_OnTreeViewClick(IRegTreeOptions *pRTO, HWND hWndTree)
Definition: performance.c:31
static INT_PTR CALLBACK AdvancedDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: performance.c:114
VOID ShowPerformanceOptions(HWND hDlg)
Definition: performance.c:137
static BOOL RegTreeOpt_OnTreeViewKeyDown(IRegTreeOptions *pRTO, HWND hWndTree, TV_KEYDOWN *pKey)
Definition: performance.c:43
static VOID RegTreeOpt_OnDestroy(IRegTreeOptions *pRTO)
Definition: performance.c:15
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSM_REMOVEPAGE
Definition: prsht.h:166
#define PSN_APPLY
Definition: prsht.h:117
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
#define TVN_KEYDOWN
Definition: commctrl.h:3718
#define TV_HITTESTINFO
Definition: commctrl.h:3521
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3478
#define NM_CLICK
Definition: commctrl.h:130
#define TV_KEYDOWN
Definition: commctrl.h:3727
#define TreeView_HitTest(hwnd, lpht)
Definition: commctrl.h:3518
#define WM_NOTIFY
Definition: richedit.h:61
@ WALK_TREE_REFRESH
Definition: shlobj_undoc.h:498
@ WALK_TREE_DESTROY
Definition: shlobj_undoc.h:496
@ WALK_TREE_SAVE
Definition: shlobj_undoc.h:495
#define _countof(array)
Definition: sndvol32.h:70
LPCPROPSHEETPAGEW ppsp
Definition: prsht.h:308
HINSTANCE hInstance
Definition: prsht.h:296
HWND hwndParent
Definition: prsht.h:295
LPCWSTR pszCaption
Definition: prsht.h:301
DLGPROC pfnDlgProc
Definition: prsht.h:226
DWORD dwSize
Definition: prsht.h:214
LPCWSTR pszTemplate
Definition: prsht.h:218
HINSTANCE hInstance
Definition: prsht.h:216
Definition: inflate.c:139
int32_t INT_PTR
Definition: typedefs.h:64
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define DWLP_USER
Definition: winuser.h:883
#define GetWindowLongPtrW
Definition: winuser.h:4931
DWORD WINAPI GetMessagePos(void)
Definition: message.c:1351
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4501
#define VK_SPACE
Definition: winuser.h:2255
#define WM_COMMAND
Definition: winuser.h:1768
#define WM_INITDIALOG
Definition: winuser.h:1767
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_SETTINGCHANGE
Definition: winuser.h:1657
#define VK_F5
Definition: winuser.h:2295
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define PostMessage
Definition: winuser.h:5943
HWND WINAPI GetParent(_In_ HWND)
#define WM_DESTROY
Definition: winuser.h:1637
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SetWindowLongPtrW
Definition: winuser.h:5457
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
const char * LPCSTR
Definition: xmlstorage.h:183