ReactOS  0.4.11-dev-433-g473ca91
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
33 LPCWSTR g_pszShell32 = L"%SystemRoot%\\system32\\shell32.dll";
34 
35 // the space characters
36 LPCWSTR 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));
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;
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 
64  HBITMAP hbm = Create24BppBitmap(hDC, cx, cy);
65  if (!hbm)
66  {
67  DeleteDC(hDC);
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);
81  DeleteDC(hDC);
82 
83  return hbm;
84 }
85 
87 {
88  INT cxSmallIcon = GetSystemMetrics(SM_CXSMICON);
89  INT cySmallIcon = GetSystemMetrics(SM_CYSMICON);
90 
91  HBITMAP hbm = Create24BppBitmap(hDC, cxSmallIcon, cySmallIcon);
92  if (hbm == NULL)
93  return NULL; // failure
94 
95  RECT Rect, BoxRect;
96  SetRect(&Rect, 0, 0, cxSmallIcon, cySmallIcon);
97  BoxRect = Rect;
98  InflateRect(&BoxRect, -1, -1);
99 
100  HGDIOBJ hbmOld = SelectObject(hDC, hbm);
101  {
103  if (bCheck)
104  uState |= DFCS_CHECKED;
105  if (!bEnabled)
106  uState |= DFCS_INACTIVE;
107  DrawFrameControl(hDC, &BoxRect, DFC_BUTTON, uState);
108  }
109  SelectObject(hDC, hbmOld);
110 
111  return hbm; // success
112 }
113 
115 {
116  INT cxSmallIcon = GetSystemMetrics(SM_CXSMICON);
117  INT cySmallIcon = GetSystemMetrics(SM_CYSMICON);
118 
119  HBITMAP hbm = CreateBitmap(cxSmallIcon, cySmallIcon, 1, 1, NULL);
120  if (hbm == NULL)
121  return NULL; // failure
122 
123  RECT Rect, BoxRect;
124  SetRect(&Rect, 0, 0, cxSmallIcon, cySmallIcon);
125  BoxRect = Rect;
126  InflateRect(&BoxRect, -1, -1);
127 
128  HGDIOBJ hbmOld = SelectObject(hDC, hbm);
129  {
130  FillRect(hDC, &Rect, HBRUSH(GetStockObject(WHITE_BRUSH)));
131  FillRect(hDC, &BoxRect, HBRUSH(GetStockObject(BLACK_BRUSH)));
132  }
133  SelectObject(hDC, hbmOld);
134 
135  return hbm; // success
136 }
137 
139 {
140  INT cxSmallIcon = GetSystemMetrics(SM_CXSMICON);
141  INT cySmallIcon = GetSystemMetrics(SM_CYSMICON);
142 
143  HBITMAP hbm = Create24BppBitmap(hDC, cxSmallIcon, cySmallIcon);
144  if (hbm == NULL)
145  return NULL; // failure
146 
147  RECT Rect, BoxRect;
148  SetRect(&Rect, 0, 0, cxSmallIcon, cySmallIcon);
149  BoxRect = Rect;
150  InflateRect(&BoxRect, -1, -1);
151 
152  HGDIOBJ hbmOld = SelectObject(hDC, hbm);
153  {
155  if (bCheck)
156  uState |= DFCS_CHECKED;
157  if (!bEnabled)
158  uState |= DFCS_INACTIVE;
159  DrawFrameControl(hDC, &BoxRect, DFC_BUTTON, uState);
160  }
161  SelectObject(hDC, hbmOld);
162 
163  return hbm; // success
164 }
165 
167 {
168  INT cxSmallIcon = GetSystemMetrics(SM_CXSMICON);
169  INT cySmallIcon = GetSystemMetrics(SM_CYSMICON);
170 
171  HBITMAP hbm = CreateBitmap(cxSmallIcon, cySmallIcon, 1, 1, NULL);
172  if (hbm == NULL)
173  return NULL; // failure
174 
175  RECT Rect, BoxRect;
176  SetRect(&Rect, 0, 0, cxSmallIcon, cySmallIcon);
177  BoxRect = Rect;
178  InflateRect(&BoxRect, -1, -1);
179 
180  HGDIOBJ hbmOld = SelectObject(hDC, hbm);
181  {
182  FillRect(hDC, &Rect, HBRUSH(GetStockObject(WHITE_BRUSH)));
184  DrawFrameControl(hDC, &BoxRect, DFC_BUTTON, uState);
185  }
186  SelectObject(hDC, hbmOld);
187 
188  return hbm; // success
189 }
190 
192 
193 EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj);
194 
195 static VOID
197 {
198  PROPSHEETHEADERW pinfo;
199  HPROPSHEETPAGE hppages[3];
200  HPROPSHEETPAGE hpage;
201  UINT num_pages = 0;
202  WCHAR szOptions[100];
203 
205  if (hpage)
206  hppages[num_pages++] = hpage;
207 
209  if (hpage)
210  hppages[num_pages++] = hpage;
211 
213  if (hpage)
214  hppages[num_pages++] = hpage;
215 
216  szOptions[0] = 0;
217  LoadStringW(shell32_hInstance, IDS_FOLDER_OPTIONS, szOptions, _countof(szOptions));
218  szOptions[_countof(szOptions) - 1] = 0;
219 
220  memset(&pinfo, 0x0, sizeof(PROPSHEETHEADERW));
221  pinfo.dwSize = sizeof(PROPSHEETHEADERW);
222  pinfo.dwFlags = PSH_NOCONTEXTHELP;
223  pinfo.nPages = num_pages;
224  pinfo.phpage = hppages;
225  pinfo.pszCaption = szOptions;
226 
227  PropertySheetW(&pinfo);
228 }
229 
230 static VOID
232 {
233  switch(fOptions)
234  {
235  case 0:
236  ShowFolderOptionsDialog(hWnd, hInst);
237  break;
238 
239  case 1:
240  // show taskbar options dialog
241  FIXME("notify explorer to show taskbar options dialog");
242  //PostMessage(GetShellWindow(), WM_USER+22, fOptions, 0);
243  break;
244 
245  default:
246  FIXME("unrecognized options id %d\n", fOptions);
247  }
248 }
249 
250 /*************************************************************************
251  * Options_RunDLL (SHELL32.@)
252  */
255 {
256  Options_RunDLLCommon(hWnd, hInst, StrToIntA(cmd), nCmdShow);
257 }
258 
259 /*************************************************************************
260  * Options_RunDLLA (SHELL32.@)
261  */
264 {
265  Options_RunDLLCommon(hWnd, hInst, StrToIntA(cmd), nCmdShow);
266 }
267 
268 /*************************************************************************
269  * Options_RunDLLW (SHELL32.@)
270  */
273 {
274  Options_RunDLLCommon(hWnd, hInst, StrToIntW(cmd), nCmdShow);
275 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define HDC
Definition: msvc.h:22
#define DFCS_FLAT
Definition: winuser.h:510
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
static HICON
Definition: imagelist.c:84
#define DFC_BUTTON
Definition: winuser.h:476
#define HBITMAP
Definition: msvc.h:28
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
#define DFCS_CHECKED
Definition: winuser.h:504
Definition: ftp_var.h:139
LPCWSTR g_pszShell32
__wchar_t WCHAR
Definition: xmlstorage.h:180
HBITMAP CreateRadioMask(HDC hDC)
#define _countof(array)
Definition: fontsub.cpp:30
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
static VOID ShowFolderOptionsDialog(HWND hWnd, HINSTANCE hInst)
static VOID Options_RunDLLCommon(HWND hWnd, HINSTANCE hInst, int fOptions, DWORD nCmdShow)
#define DFCS_INACTIVE
Definition: winuser.h:502
HWND hWnd
Definition: settings.c:17
HANDLE HWND
Definition: compat.h:13
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ZeroMemory
Definition: winbase.h:1635
#define SM_CYSMICON
Definition: winuser.h:1003
#define WHITE_BRUSH
Definition: wingdi.h:900
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
struct _PROPSHEETHEADERW PROPSHEETHEADERW
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
HBITMAP CreateCheckMask(HDC hDC)
DWORD DWORD
Definition: winlogon.h:84
EXTERN_C VOID WINAPI Options_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow)
HBITMAP Create24BppBitmap(HDC hDC, INT cx, INT cy)
#define COLOR_3DFACE
Definition: winuser.h:919
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
LPCWSTR pszCaption
Definition: prsht.h:283
HBITMAP CreateCheckImage(HDC hDC, BOOL bCheck, BOOL bEnabled)
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
#define IDS_FOLDER_OPTIONS
Definition: shresdef.h:232
#define FIXME(fmt,...)
Definition: debug.h:110
DWORD biCompression
Definition: amvideo.idl:35
UINT uState
Definition: wglext.h:781
LPCWSTR g_pszSpace
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
smooth NULL
Definition: ftsmooth.c:416
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2896
const char * LPCSTR
Definition: xmlstorage.h:183
#define BLACK_BRUSH
Definition: wingdi.h:894
HDC hDC
Definition: wglext.h:521
unsigned int BOOL
Definition: ntddk_ex.h:94
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:1997
HANDLE HKEY
Definition: registry.h:24
WINE_DEFAULT_DEBUG_CHANNEL(fprop)
#define DFCS_MONO
Definition: winuser.h:511
int WINAPI GetSystemMetrics(_In_ int)
DWORD dwSize
Definition: prsht.h:275
DWORD dwFlags
Definition: prsht.h:276
#define SM_CXSMICON
Definition: winuser.h:1002
HANDLE HINSTANCE
Definition: typedefs.h:75
INT_PTR CALLBACK FolderOptionsFileTypesDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filetypes.cpp:1664
static const WCHAR L[]
Definition: oid.c:1087
#define IDD_FOLDER_OPTIONS_GENERAL
Definition: shresdef.h:329
HBITMAP CreateRadioImage(HDC hDC, BOOL bCheck, BOOL bEnabled)
#define DI_NORMAL
Definition: wingdi.h:72
EXTERN_C VOID WINAPI Options_RunDLL(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow)
#define WINAPI
Definition: msvc.h:20
#define IDD_FOLDER_OPTIONS_FILETYPES
Definition: shresdef.h:331
HPROPSHEETPAGE * phpage
Definition: prsht.h:291
#define DFCS_BUTTONCHECK
Definition: winuser.h:496
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
HINSTANCE hInst
Definition: dxdiag.c:13
#define IDD_FOLDER_OPTIONS_VIEW
Definition: shresdef.h:330
BOOL WINAPI DeleteDC(_In_ HDC)
INT_PTR CALLBACK FolderOptionsViewDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: view.cpp:934
HICON hIcon
Definition: msconfig.c:44
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
unsigned int UINT
Definition: ndis.h:50
EXTERN_C VOID WINAPI Options_RunDLLA(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow)
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:411
_Out_opt_ int * cx
Definition: commctrl.h:570
HBITMAP BitmapFromIcon(HICON hIcon, INT cx, INT cy)
EXTERN_C HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface, IDataObject *pDataObj)
INT WINAPI StrToIntA(LPCSTR lpszStr)
Definition: string.c:374
HPROPSHEETPAGE SH_CreatePropertySheetPage(LPCSTR resname, DLGPROC dlgproc, LPARAM lParam, LPWSTR szTitle)
#define DFCS_BUTTONRADIOMASK
Definition: winuser.h:498
#define DIB_RGB_COLORS
Definition: wingdi.h:365
#define EXTERN_C
Definition: basetyps.h:12
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define memset(x, y, z)
Definition: compat.h:39
INT_PTR CALLBACK FolderOptionsGeneralDlg(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: general.cpp:365
#define BI_RGB
Definition: precomp.h:35
#define DFCS_BUTTONRADIOIMAGE
Definition: winuser.h:497
struct Rect Rect
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)