ReactOS 0.4.17-dev-243-g1369312
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#include <shlwapi_undoc.h> // SHSendMessageBroadcastW
14
15static VOID
16RegTreeOpt_OnDestroy(IRegTreeOptions *pRTO)
17{
18 if (pRTO)
19 {
20 IRegTreeOptions_WalkTree(pRTO, WALK_TREE_DESTROY);
21 IRegTreeOptions_Release(pRTO);
22 }
23}
24
25static BOOL
27{
28 return pRTO && SUCCEEDED(IRegTreeOptions_ToggleItem(pRTO, hItem));
29}
30
31static BOOL
32RegTreeOpt_OnTreeViewClick(IRegTreeOptions *pRTO, HWND hWndTree)
33{
34 TV_HITTESTINFO HitTest;
35 DWORD dwPos = GetMessagePos();
36 HitTest.pt.x = GET_X_LPARAM(dwPos);
37 HitTest.pt.y = GET_Y_LPARAM(dwPos);
38 ScreenToClient(hWndTree, &HitTest.pt);
39 HTREEITEM hItem = TreeView_HitTest(hWndTree, &HitTest);
41}
42
43static BOOL
44RegTreeOpt_OnTreeViewKeyDown(IRegTreeOptions *pRTO, HWND hWndTree, TV_KEYDOWN *pKey)
45{
46 if (pKey->wVKey == VK_SPACE)
48 else if (pKey->wVKey == VK_F5 && pRTO)
49 IRegTreeOptions_WalkTree(pRTO, WALK_TREE_REFRESH);
50 return FALSE;
51}
52
53static INT_PTR CALLBACK
55{
56 IRegTreeOptions *pRTO = (IRegTreeOptions*)GetWindowLongPtrW(hDlg, DWLP_USER);
57 HWND hWndTree = GetDlgItem(hDlg, IDC_TREE);
58
59 switch (uMsg)
60 {
61 case WM_INITDIALOG:
62 {
63 IRegTreeOptions *pRTO = NULL;
64 if (SUCCEEDED(CoCreateInstance(&CLSID_CRegTreeOptions, NULL, CLSCTX_INPROC_SERVER,
65 &IID_IRegTreeOptions, (void**)&pRTO)))
66 {
67 LPCSTR pszPath = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VisualEffects";
69 IRegTreeOptions_InitTree(pRTO, hWndTree, HKEY_LOCAL_MACHINE, pszPath, NULL);
70 }
71 else
72 {
73 // Without IRegTreeOptions, our page is pointless so we remove it.
74 // MSDN says we have to post the remove message from inside WM_INITDIALOG.
75 HWND hWndPS = GetParent(hDlg);
76 int iPage = PropSheet_HwndToIndex(hWndPS, hDlg);
77 PostMessage(hWndPS, PSM_REMOVEPAGE, 0, SendMessageW(hWndPS, PSM_INDEXTOPAGE, iPage, 0));
78 }
79 return TRUE;
80 }
81
82 case WM_DESTROY:
85 break;
86
87 case WM_NOTIFY:
88 switch (((LPNMHDR)lParam)->code)
89 {
90 case NM_CLICK:
91 if (RegTreeOpt_OnTreeViewClick(pRTO, hWndTree))
92 PropSheet_Changed(GetParent(hDlg), hDlg);
93 break;
94
95 case TVN_KEYDOWN:
96 if (RegTreeOpt_OnTreeViewKeyDown(pRTO, hWndTree, (TV_KEYDOWN*)lParam))
97 PropSheet_Changed(GetParent(hDlg), hDlg);
98 break;
99
100 case PSN_APPLY:
101 {
102 if (pRTO)
103 IRegTreeOptions_WalkTree(pRTO, WALK_TREE_SAVE);
104
105 SHSendMessageBroadcastW(WM_SETTINGCHANGE, 0, 0); // For the ListviewShadow setting
106 return TRUE;
107 }
108 }
109 break;
110 }
111 return FALSE;
112}
113
114static INT_PTR CALLBACK
116{
117 switch (uMsg)
118 {
119 case WM_INITDIALOG:
120 // TODO: Not implemented yet
123 return TRUE;
124
125 case WM_COMMAND:
126 switch (LOWORD(wParam))
127 {
128 case IDC_CHANGESWAP:
130 break;
131 }
132 break;
133 }
134 return FALSE;
135}
136
137VOID
139{
140 HRESULT hrInit = CoInitialize(NULL); // For IRegTreeOptions
141 PROPSHEETHEADERW psh = { sizeof(psh), PSH_PROPSHEETPAGE | PSH_NOCONTEXTHELP };
142 PROPSHEETPAGEW pages[2] = { 0 };
143
144 pages[0].dwSize = sizeof(*pages);
145 pages[0].hInstance = hApplet;
148
149 pages[1].dwSize = sizeof(*pages);
150 pages[1].hInstance = hApplet;
152 pages[1].pfnDlgProc = AdvancedDlgProc;
153
154 psh.hwndParent = hDlg;
155 psh.hInstance = hApplet;
157 psh.nPages = _countof(pages);
158 psh.ppsp = pages;
159
160 PropertySheetW(&psh);
161
162 if (SUCCEEDED(hrInit))
164}
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
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2916
#define CALLBACK
Definition: compat.h:35
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
DWORD WINAPI SHSendMessageBroadcastW(UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ordinal.c:4195
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
LONG_PTR LPARAM
Definition: minwindef.h:175
UINT_PTR WPARAM
Definition: minwindef.h:174
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:54
static BOOL RegTreeOpt_ToggleCheckItem(IRegTreeOptions *pRTO, HTREEITEM hItem)
Definition: performance.c:26
static BOOL RegTreeOpt_OnTreeViewClick(IRegTreeOptions *pRTO, HWND hWndTree)
Definition: performance.c:32
static INT_PTR CALLBACK AdvancedDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: performance.c:115
VOID ShowPerformanceOptions(HWND hDlg)
Definition: performance.c:138
static BOOL RegTreeOpt_OnTreeViewKeyDown(IRegTreeOptions *pRTO, HWND hWndTree, TV_KEYDOWN *pKey)
Definition: performance.c:44
static VOID RegTreeOpt_OnDestroy(IRegTreeOptions *pRTO)
Definition: performance.c:16
#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:518
@ WALK_TREE_DESTROY
Definition: shlobj_undoc.h:516
@ WALK_TREE_SAVE
Definition: shlobj_undoc.h:515
#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
const char * LPCSTR
Definition: typedefs.h:52
int32_t INT_PTR
Definition: typedefs.h:64
#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:4983
DWORD WINAPI GetMessagePos(void)
Definition: message.c:1351
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4553
#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:5998
HWND WINAPI GetParent(_In_ HWND)
#define WM_DESTROY
Definition: winuser.h:1637
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SetWindowLongPtrW
Definition: winuser.h:5512
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)