4 * Copyright 2007 Johannes Anderwald <johannes.anderwald@reactos.org>
5 * Copyright 2016-2018 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
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.
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.
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
24 WINE_DEFAULT_DEBUG_CHANNEL (fprop
);
27 // CLASSKEY = HKEY_CLASSES_ROOT\CLSID\{6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}
29 /////////////////////////////////////////////////////////////////////////////
33 LPCWSTR g_pszShell32
= L
"%SystemRoot%\\system32\\shell32.dll";
35 // the space characters
36 LPCWSTR g_pszSpace
= L
" \t\n\r\f\v";
38 /////////////////////////////////////////////////////////////////////////////
41 HBITMAP
Create24BppBitmap(HDC hDC
, INT cx
, INT cy
)
46 ZeroMemory(&bi
, sizeof(bi
));
47 bi
.bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
48 bi
.bmiHeader
.biWidth
= cx
;
49 bi
.bmiHeader
.biHeight
= cy
;
50 bi
.bmiHeader
.biPlanes
= 1;
51 bi
.bmiHeader
.biBitCount
= 24;
52 bi
.bmiHeader
.biCompression
= BI_RGB
;
54 HBITMAP hbm
= CreateDIBSection(hDC
, &bi
, DIB_RGB_COLORS
, &pvBits
, NULL
, 0);
58 HBITMAP
BitmapFromIcon(HICON hIcon
, INT cx
, INT cy
)
60 HDC hDC
= CreateCompatibleDC(NULL
);
64 HBITMAP hbm
= Create24BppBitmap(hDC
, cx
, cy
);
71 HGDIOBJ hbmOld
= SelectObject(hDC
, hbm
);
73 RECT rc
= { 0, 0, cx
, cy
};
74 FillRect(hDC
, &rc
, HBRUSH(COLOR_3DFACE
+ 1));
77 DrawIconEx(hDC
, 0, 0, hIcon
, cx
, cy
, 0, NULL
, DI_NORMAL
);
80 SelectObject(hDC
, hbmOld
);
86 HBITMAP
CreateCheckImage(HDC hDC
, BOOL bCheck
, BOOL bEnabled
)
88 INT cxSmallIcon
= GetSystemMetrics(SM_CXSMICON
);
89 INT cySmallIcon
= GetSystemMetrics(SM_CYSMICON
);
91 HBITMAP hbm
= Create24BppBitmap(hDC
, cxSmallIcon
, cySmallIcon
);
93 return NULL
; // failure
96 SetRect(&Rect
, 0, 0, cxSmallIcon
, cySmallIcon
);
98 InflateRect(&BoxRect
, -1, -1);
100 HGDIOBJ hbmOld
= SelectObject(hDC
, hbm
);
102 UINT uState
= DFCS_BUTTONCHECK
| DFCS_FLAT
| DFCS_MONO
;
104 uState
|= DFCS_CHECKED
;
106 uState
|= DFCS_INACTIVE
;
107 DrawFrameControl(hDC
, &BoxRect
, DFC_BUTTON
, uState
);
109 SelectObject(hDC
, hbmOld
);
111 return hbm
; // success
114 HBITMAP
CreateCheckMask(HDC hDC
)
116 INT cxSmallIcon
= GetSystemMetrics(SM_CXSMICON
);
117 INT cySmallIcon
= GetSystemMetrics(SM_CYSMICON
);
119 HBITMAP hbm
= CreateBitmap(cxSmallIcon
, cySmallIcon
, 1, 1, NULL
);
121 return NULL
; // failure
124 SetRect(&Rect
, 0, 0, cxSmallIcon
, cySmallIcon
);
126 InflateRect(&BoxRect
, -1, -1);
128 HGDIOBJ hbmOld
= SelectObject(hDC
, hbm
);
130 FillRect(hDC
, &Rect
, HBRUSH(GetStockObject(WHITE_BRUSH
)));
131 FillRect(hDC
, &BoxRect
, HBRUSH(GetStockObject(BLACK_BRUSH
)));
133 SelectObject(hDC
, hbmOld
);
135 return hbm
; // success
138 HBITMAP
CreateRadioImage(HDC hDC
, BOOL bCheck
, BOOL bEnabled
)
140 INT cxSmallIcon
= GetSystemMetrics(SM_CXSMICON
);
141 INT cySmallIcon
= GetSystemMetrics(SM_CYSMICON
);
143 HBITMAP hbm
= Create24BppBitmap(hDC
, cxSmallIcon
, cySmallIcon
);
145 return NULL
; // failure
148 SetRect(&Rect
, 0, 0, cxSmallIcon
, cySmallIcon
);
150 InflateRect(&BoxRect
, -1, -1);
152 HGDIOBJ hbmOld
= SelectObject(hDC
, hbm
);
154 UINT uState
= DFCS_BUTTONRADIOIMAGE
| DFCS_FLAT
| DFCS_MONO
;
156 uState
|= DFCS_CHECKED
;
158 uState
|= DFCS_INACTIVE
;
159 DrawFrameControl(hDC
, &BoxRect
, DFC_BUTTON
, uState
);
161 SelectObject(hDC
, hbmOld
);
163 return hbm
; // success
166 HBITMAP
CreateRadioMask(HDC hDC
)
168 INT cxSmallIcon
= GetSystemMetrics(SM_CXSMICON
);
169 INT cySmallIcon
= GetSystemMetrics(SM_CYSMICON
);
171 HBITMAP hbm
= CreateBitmap(cxSmallIcon
, cySmallIcon
, 1, 1, NULL
);
173 return NULL
; // failure
176 SetRect(&Rect
, 0, 0, cxSmallIcon
, cySmallIcon
);
178 InflateRect(&BoxRect
, -1, -1);
180 HGDIOBJ hbmOld
= SelectObject(hDC
, hbm
);
182 FillRect(hDC
, &Rect
, HBRUSH(GetStockObject(WHITE_BRUSH
)));
183 UINT uState
= DFCS_BUTTONRADIOMASK
| DFCS_FLAT
| DFCS_MONO
;
184 DrawFrameControl(hDC
, &BoxRect
, DFC_BUTTON
, uState
);
186 SelectObject(hDC
, hbmOld
);
188 return hbm
; // success
191 /////////////////////////////////////////////////////////////////////////////
193 // CMSGlobalFolderOptionsStub --- The owner window of Folder Options.
194 // This window hides taskbar button of Folder Options.
195 class CMSGlobalFolderOptionsStub
: public CWindowImpl
<CMSGlobalFolderOptionsStub
>
198 DECLARE_WND_CLASS_EX(_T("MSGlobalFolderOptionsStub"), 0, COLOR_WINDOWTEXT
)
200 BEGIN_MSG_MAP(CMSGlobalFolderOptionsStub
)
204 /////////////////////////////////////////////////////////////////////////////
206 EXTERN_C HPSXA WINAPI
SHCreatePropSheetExtArrayEx(HKEY hKey
, LPCWSTR pszSubKey
, UINT max_iface
, IDataObject
*pDataObj
);
209 PropSheetProc(HWND hwndDlg
, UINT uMsg
, LPARAM lParam
)
211 // NOTE: This callback is needed to set large icon correctly.
215 case PSCB_INITIALIZED
:
217 hIcon
= LoadIconW(shell32_hInstance
, MAKEINTRESOURCEW(IDI_SHELL_FOLDER_OPTIONS
));
218 SendMessageW(hwndDlg
, WM_SETICON
, ICON_BIG
, (LPARAM
)hIcon
);
226 ShowFolderOptionsDialog(HWND hWnd
, HINSTANCE hInst
)
228 PROPSHEETHEADERW pinfo
;
229 HPROPSHEETPAGE hppages
[3];
230 HPROPSHEETPAGE hpage
;
232 WCHAR szOptions
[100];
234 hpage
= SH_CreatePropertySheetPage(IDD_FOLDER_OPTIONS_GENERAL
, FolderOptionsGeneralDlg
, 0, NULL
);
236 hppages
[num_pages
++] = hpage
;
238 hpage
= SH_CreatePropertySheetPage(IDD_FOLDER_OPTIONS_VIEW
, FolderOptionsViewDlg
, 0, NULL
);
240 hppages
[num_pages
++] = hpage
;
242 hpage
= SH_CreatePropertySheetPage(IDD_FOLDER_OPTIONS_FILETYPES
, FolderOptionsFileTypesDlg
, 0, NULL
);
244 hppages
[num_pages
++] = hpage
;
247 LoadStringW(shell32_hInstance
, IDS_FOLDER_OPTIONS
, szOptions
, _countof(szOptions
));
248 szOptions
[_countof(szOptions
) - 1] = 0;
250 // the stub window to hide taskbar button
251 DWORD style
= WS_DISABLED
| WS_CLIPSIBLINGS
| WS_CAPTION
;
252 DWORD exstyle
= WS_EX_WINDOWEDGE
| WS_EX_TOOLWINDOW
;
253 CMSGlobalFolderOptionsStub stub
;
254 if (!stub
.Create(NULL
, NULL
, NULL
, style
, exstyle
))
256 ERR("stub.Create failed\n");
260 memset(&pinfo
, 0x0, sizeof(PROPSHEETHEADERW
));
261 pinfo
.dwSize
= sizeof(PROPSHEETHEADERW
);
262 pinfo
.dwFlags
= PSH_NOCONTEXTHELP
| PSH_USEICONID
| PSH_USECALLBACK
;
263 pinfo
.hwndParent
= stub
;
264 pinfo
.nPages
= num_pages
;
265 pinfo
.phpage
= hppages
;
266 pinfo
.pszIcon
= MAKEINTRESOURCEW(IDI_SHELL_FOLDER_OPTIONS
);
267 pinfo
.pszCaption
= szOptions
;
268 pinfo
.pfnCallback
= PropSheetProc
;
270 PropertySheetW(&pinfo
);
272 stub
.DestroyWindow();
276 Options_RunDLLCommon(HWND hWnd
, HINSTANCE hInst
, int fOptions
, DWORD nCmdShow
)
281 ShowFolderOptionsDialog(hWnd
, hInst
);
285 // show taskbar options dialog
286 FIXME("notify explorer to show taskbar options dialog");
287 //PostMessage(GetShellWindow(), WM_USER+22, fOptions, 0);
291 FIXME("unrecognized options id %d\n", fOptions
);
295 /*************************************************************************
296 * Options_RunDLL (SHELL32.@)
299 Options_RunDLL(HWND hWnd
, HINSTANCE hInst
, LPCSTR cmd
, DWORD nCmdShow
)
301 Options_RunDLLCommon(hWnd
, hInst
, StrToIntA(cmd
), nCmdShow
);
304 /*************************************************************************
305 * Options_RunDLLA (SHELL32.@)
308 Options_RunDLLA(HWND hWnd
, HINSTANCE hInst
, LPCSTR cmd
, DWORD nCmdShow
)
310 Options_RunDLLCommon(hWnd
, hInst
, StrToIntA(cmd
), nCmdShow
);
313 /*************************************************************************
314 * Options_RunDLLW (SHELL32.@)
317 Options_RunDLLW(HWND hWnd
, HINSTANCE hInst
, LPCWSTR cmd
, DWORD nCmdShow
)
319 Options_RunDLLCommon(hWnd
, hInst
, StrToIntW(cmd
), nCmdShow
);