ReactOS 0.4.16-dev-1278-gd809cd0
folder_options.cpp
Go to the documentation of this file.
1/*
2 * Folder Options
3 *
4 * Copyright 2007 Johannes Anderwald <johannes.anderwald@reactos.org>
5 * Copyright 2016-2018 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#include "precomp.h"
23
25
26// Folder Options:
27// CLASSKEY = HKEY_CLASSES_ROOT\CLSID\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}
28
30// strings
31
32// path to shell32
33LPCWSTR g_pszShell32 = L"%SystemRoot%\\system32\\shell32.dll";
34
35// the space characters
36LPCWSTR g_pszSpace = L" \t\n\r\f\v";
37
39// utility functions
40
42{
43 BITMAPINFO bi;
44 LPVOID pvBits;
45
46 ZeroMemory(&bi, sizeof(bi));
48 bi.bmiHeader.biWidth = cx;
50 bi.bmiHeader.biPlanes = 1;
51 bi.bmiHeader.biBitCount = 24;
53
54 HBITMAP hbm = CreateDIBSection(hDC, &bi, DIB_RGB_COLORS, &pvBits, NULL, 0);
55 return hbm;
56}
57
59{
61 if (!hDC)
62 return NULL;
63
65 if (!hbm)
66 {
68 return NULL;
69 }
70
71 HGDIOBJ hbmOld = SelectObject(hDC, hbm);
72 {
73 RECT rc = { 0, 0, cx, cy };
74 FillRect(hDC, &rc, HBRUSH(COLOR_3DFACE + 1));
75 if (hIcon)
76 {
77 DrawIconEx(hDC, 0, 0, hIcon, cx, cy, 0, NULL, DI_NORMAL);
78 }
79 }
80 SelectObject(hDC, hbmOld);
82
83 return hbm;
84}
85
86
88
89// CMSGlobalFolderOptionsStub --- The owner window of Folder Options.
90// This window hides taskbar button of Folder Options.
91
92#define GlobalFolderOptionsClassName _T("MSGlobalFolderOptionsStub")
93
94class CMSGlobalFolderOptionsStub : public CWindowImpl<CMSGlobalFolderOptionsStub>
95{
96public:
98
101};
102
104
106
107static int CALLBACK
109{
110 // NOTE: This callback is needed to set large icon correctly.
111 HICON hIcon;
112 switch (uMsg)
113 {
114 case PSCB_INITIALIZED:
115 {
117 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
118 break;
119 }
120 }
121 return 0;
122}
123
124enum {
129
130static DWORD CALLBACK
132{
133 CCoInit com; // Required when started from rundll32 (IRegTreeOptions, SHAutoComplete (in PickIconDlg))
134 PROPSHEETHEADERW pinfo;
135 HPROPSHEETPAGE hppages[3];
136 HPROPSHEETPAGE hpage;
137 UINT num_pages = 0;
138
140 if (hpage)
141 hppages[num_pages++] = hpage;
142
144 if (hpage)
145 hppages[num_pages++] = hpage;
146
148 if (hpage)
149 hppages[num_pages++] = hpage;
150
151 // the stub window to hide taskbar button
155 if (!stub.Create(NULL, NULL, NULL, style, exstyle))
156 {
157 ERR("stub.Create failed\n");
158 return 0;
159 }
160
161 memset(&pinfo, 0x0, sizeof(PROPSHEETHEADERW));
162 pinfo.dwSize = sizeof(PROPSHEETHEADERW);
163 pinfo.dwFlags = PSH_NOCONTEXTHELP | PSH_USEICONID | PSH_USECALLBACK;
164 pinfo.hwndParent = stub;
165 pinfo.nPages = num_pages;
166 pinfo.phpage = hppages;
171 pinfo.nStartPage = PtrToUlong(param);
172
173 PropertySheetW(&pinfo);
174
175 stub.DestroyWindow();
176 return 0;
177}
178
181{
183 if (hWnd)
184 {
186 if (hWnd == GetParent(hPop))
187 {
188 PostMessage(hPop, PSM_SETCURSEL, Page, 0);
189 }
191 return;
192 }
193
195 if (Async)
197 else
198 ShowFolderOptionsDialogThreadProc(param); // Rundll32 caller cannot be async!
199}
200
201static VOID
203{
204 switch(fOptions)
205 {
206 case 0:
208 break;
209
210 case 1: // Taskbar settings
211#if (NTDDI_VERSION >= NTDDI_VISTA)
212 case 3: // Start menu settings
213 case 4: // Tray icon settings
214 case 6: // Taskbar toolbars
215#endif
217 break;
218
219 case 7: // Windows 8, 10
221 break;
222
223 default:
224 FIXME("unrecognized options id %d\n", fOptions);
225 }
226}
227
228/*************************************************************************
229 * Options_RunDLL (SHELL32.@)
230 */
233{
235}
236
237/*************************************************************************
238 * Options_RunDLLA (SHELL32.@)
239 */
242{
244}
245
246/*************************************************************************
247 * Options_RunDLLW (SHELL32.@)
248 */
251{
253}
static HDC hDC
Definition: 3dtext.c:33
INT_PTR CALLBACK FolderOptionsViewDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: view.cpp:208
INT_PTR CALLBACK FolderOptionsFileTypesDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:1872
INT_PTR CALLBACK FolderOptionsGeneralDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: general.cpp:351
#define shell32_hInstance
Arabic default style
Definition: afstyles.h:94
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
#define EXTERN_C
Definition: basetyps.h:12
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define IDS_FOLDER_OPTIONS
Definition: resource.h:135
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2916
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:407
INT WINAPI StrToIntA(LPCSTR lpszStr)
Definition: string.c:370
#define CALLBACK
Definition: compat.h:35
BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE pfnThreadProc, VOID *pData, DWORD dwFlags, LPTHREAD_START_ROUTINE pfnCallback)
Definition: thread.c:356
#define BI_RGB
Definition: precomp.h:56
#define UlongToPtr(u)
Definition: config.h:106
#define PtrToUlong(u)
Definition: config.h:107
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
EXTERN_C VOID WINAPI Options_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow)
EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj)
EXTERN_C VOID WINAPI Options_RunDLLA(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow)
LPCWSTR g_pszSpace
HBITMAP Create24BppBitmap(HDC hDC, INT cx, INT cy)
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
#define GlobalFolderOptionsClassName
LPCWSTR g_pszShell32
VOID WINAPI ShowFolderOptionsDialog(UINT Page, BOOL Async=FALSE)
static DWORD CALLBACK ShowFolderOptionsDialogThreadProc(LPVOID param)
EXTERN_C VOID WINAPI Options_RunDLL(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow)
static VOID Options_RunDLLCommon(HWND hWnd, HINSTANCE hInst, int fOptions, DWORD nCmdShow)
HBITMAP BitmapFromIcon(HICON hIcon, INT cx, INT cy)
@ PAGE_FILETYPES
@ PAGE_VIEW
@ PAGE_GENERAL
FxAutoRegKey hKey
GLfloat param
Definition: glext.h:5796
#define BEGIN_MSG_MAP(theClass)
Definition: atlwin.h:1898
#define END_MSG_MAP()
Definition: atlwin.h:1917
#define DECLARE_WND_CLASS_EX(WndClassName, style, bkgnd)
Definition: atlwin.h:2004
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
unsigned int UINT
Definition: ndis.h:50
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
Definition: mm.h:1306
#define L(x)
Definition: ntvdm.h:50
#define WS_CAPTION
Definition: pedump.c:624
#define WS_DISABLED
Definition: pedump.c:621
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define PSH_USECALLBACK
Definition: prsht.h:48
#define PSH_USEICONID
Definition: prsht.h:42
#define PSCB_INITIALIZED
Definition: prsht.h:75
struct _PROPSHEETHEADERW PROPSHEETHEADERW
#define PSM_SETCURSEL
Definition: prsht.h:167
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define memset(x, y, z)
Definition: compat.h:39
#define IDD_FOLDER_OPTIONS_FILETYPES
Definition: shresdef.h:442
#define IDD_FOLDER_OPTIONS_GENERAL
Definition: shresdef.h:440
#define IDI_SHELL_FOLDER_OPTIONS
Definition: shresdef.h:696
#define IDD_FOLDER_OPTIONS_VIEW
Definition: shresdef.h:441
HINSTANCE hInstance
Definition: prsht.h:296
DWORD dwSize
Definition: prsht.h:293
DWORD dwFlags
Definition: prsht.h:294
LPCWSTR pszIcon
Definition: prsht.h:299
HWND hwndParent
Definition: prsht.h:295
PFNPROPSHEETCALLBACK pfnCallback
Definition: prsht.h:311
HPROPSHEETPAGE * phpage
Definition: prsht.h:309
UINT nStartPage
Definition: prsht.h:304
LPCWSTR pszCaption
Definition: prsht.h:301
Definition: stubgen.c:11
Definition: ftp_var.h:139
USHORT biBitCount
Definition: precomp.h:46
ULONG biCompression
Definition: precomp.h:47
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
struct _stub stub
#define ICON_BIG
Definition: tnclass.cpp:51
int32_t INT
Definition: typedefs.h:58
#define WM_PROGMAN_OPENSHELLSETTINGS
Definition: undocshell.h:63
HPROPSHEETPAGE SH_CreatePropertySheetPage(WORD wDialogId, DLGPROC pfnDlgProc, LPARAM lParam, LPCWSTR pwszTitle)
Definition: propsheet.cpp:243
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
HWND WINAPI GetShellWindow(void)
Definition: input.c:974
#define ZeroMemory
Definition: winbase.h:1753
LONG_PTR LPARAM
Definition: windef.h:208
#define WINAPI
Definition: msvc.h:6
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define DI_NORMAL
Definition: wingdi.h:72
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI DeleteDC(_In_ HDC)
#define FindWindow
Definition: winuser.h:5862
#define COLOR_WINDOWTEXT
Definition: winuser.h:932
HWND WINAPI GetLastActivePopup(_In_ HWND)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:2365
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define PostMessage
Definition: winuser.h:5917
HWND WINAPI GetParent(_In_ HWND)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2412
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define COLOR_3DFACE
Definition: winuser.h:940
const char * LPCSTR
Definition: xmlstorage.h:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185