ReactOS 0.4.16-dev-1493-ge7358c5
regtreeoptions.cpp File Reference
#include "precomp.h"
Include dependency graph for regtreeoptions.cpp:

Go to the source code of this file.

Macros

#define HKEY_GRAYED   HKEY_REGTREEOPTION_GRAYED
 
#define MAXVALUEDATA   100
 

Enumerations

enum  {
  TYPE_CHECK = 0 , TYPE_RADIO , TYPE_GROUP , TYPE_INVALID ,
  STATEIMAGESPERTYPE = 4 , STATE_CHECKOFF = TYPE_CHECK * STATEIMAGESPERTYPE , STATE_CHECKON , STATE_RADIOOFF = TYPE_RADIO * STATEIMAGESPERTYPE ,
  STATE_RADIOON , STATE_GROUP = TYPE_GROUP * STATEIMAGESPERTYPE , REG_GET_DIRECT = -1
}
 

Functions

 C_ASSERT ((STATE_CHECKON &1) &&(STATE_RADIOON &1) &&STATE_RADIOON< STATE_GROUP)
 
static HBITMAP CreatDibBitmap (HDC hDC, UINT cx, UINT cy, UINT bpp)
 
static HIMAGELIST CreateStateImages (UINT ImageSize)
 
static DWORD NormalizeRegType (DWORD Type)
 
static DWORD GetRegDWORD (HKEY hKey, LPCWSTR Name, PDWORD Data)
 
static DWORD GetRegDWORD (HKEY hKey, LPCWSTR Name, DWORD Default)
 
static HRESULT GetRegString (HKEY hKey, LPCWSTR Name, LPWSTR Buffer, DWORD cchBuffer)
 
static int AddIconFromRegistry (HIMAGELIST hIL, HKEY hKey, LPCWSTR Name)
 
static HRESULT GetDefaultValue (HKEY hKey, DWORD &Type, LPVOID Data, DWORD &Size)
 

Macro Definition Documentation

◆ HKEY_GRAYED

#define HKEY_GRAYED   HKEY_REGTREEOPTION_GRAYED

Definition at line 10 of file regtreeoptions.cpp.

◆ MAXVALUEDATA

#define MAXVALUEDATA   100

Definition at line 11 of file regtreeoptions.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TYPE_CHECK 
TYPE_RADIO 
TYPE_GROUP 
TYPE_INVALID 
STATEIMAGESPERTYPE 
STATE_CHECKOFF 
STATE_CHECKON 
STATE_RADIOOFF 
STATE_RADIOON 
STATE_GROUP 
REG_GET_DIRECT 

Definition at line 13 of file regtreeoptions.cpp.

13 {
14 TYPE_CHECK = 0,
24 REG_GET_DIRECT = -1,
25};
@ TYPE_RADIO
@ TYPE_CHECK
@ STATEIMAGESPERTYPE
@ STATE_CHECKON
@ STATE_RADIOON
@ STATE_CHECKOFF
@ STATE_RADIOOFF
@ REG_GET_DIRECT
@ STATE_GROUP
@ TYPE_GROUP
@ TYPE_INVALID

Function Documentation

◆ AddIconFromRegistry()

static int AddIconFromRegistry ( HIMAGELIST  hIL,
HKEY  hKey,
LPCWSTR  Name 
)
static

Definition at line 142 of file regtreeoptions.cpp.

143{
144 WCHAR Path[MAX_PATH + 42];
145 if (GetRegString(hKey, Name, Path, _countof(Path)) > 0) // Will %expand% for us
146 {
148 HICON hIcon = NULL;
149 if (ExtractIconExW(Path, idx * -1, NULL, &hIcon, 1)) // Note: Index/Id is opposite of DefaultIcon style
150 {
153 if (idx != -1)
154 return idx;
155 }
156 }
157 return I_IMAGENONE;
158}
PRTL_UNICODE_STRING_BUFFER Path
LPWSTR Name
Definition: desk.c:124
#define NULL
Definition: types.h:112
unsigned int idx
Definition: utils.c:41
#define MAX_PATH
Definition: compat.h:34
int WINAPI PathParseIconLocationW(WCHAR *path)
Definition: path.c:2644
FxAutoRegKey hKey
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:855
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define I_IMAGENONE
Definition: commctrl.h:2391
static HRESULT GetRegString(HKEY hKey, LPCWSTR Name, LPWSTR Buffer, DWORD cchBuffer)
#define _countof(array)
Definition: sndvol32.h:70
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2405
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CRegTreeOptions::AddItemsFromRegistry().

◆ C_ASSERT()

C_ASSERT ( )

◆ CreatDibBitmap()

static HBITMAP CreatDibBitmap ( HDC  hDC,
UINT  cx,
UINT  cy,
UINT  bpp 
)
static

Definition at line 29 of file regtreeoptions.cpp.

30{
31 BITMAPINFO bi;
32 PVOID pvBits;
33
34 ZeroMemory(&bi, sizeof(bi));
35 bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
36 bi.bmiHeader.biWidth = cx;
38 bi.bmiHeader.biPlanes = 1;
41 return CreateDIBSection(hDC, &bi, DIB_RGB_COLORS, &pvBits, NULL, 0);
42}
static HDC hDC
Definition: 3dtext.c:33
DWORD bpp
Definition: surface.c:185
#define BI_RGB
Definition: precomp.h:56
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
USHORT biBitCount
Definition: precomp.h:46
ULONG biCompression
Definition: precomp.h:47
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1922
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define ZeroMemory
Definition: winbase.h:1753
#define DIB_RGB_COLORS
Definition: wingdi.h:367

Referenced by CreateStateImages().

◆ CreateStateImages()

static HIMAGELIST CreateStateImages ( UINT  ImageSize)
static

Definition at line 44 of file regtreeoptions.cpp.

45{
46 enum { bpp = 32 };
48 HIMAGELIST hIL = ImageList_Create(ImageSize, ImageSize, ILC_MASK | bpp, 8, 0);
49 if (!hIL)
50 return hIL;
51
52 INT BorderSize = max(1, min(ImageSize / 16, 4));
53 RECT Rect;
55
56 HBITMAP hbmMask = CreateBitmap(ImageSize, ImageSize, 1, 1, NULL);
57 Failed |= hbmMask == NULL;
58
59 HBITMAP hbmData = CreatDibBitmap(hDC, ImageSize, ImageSize, bpp);
60 Failed |= hbmData == NULL;
61
62 const HGDIOBJ hbmOld = SelectObject(hDC, hbmMask);
63 Failed |= hbmOld == NULL;
64
65 // Create the check images
66 SetRect(&Rect, 0, 0, ImageSize, ImageSize);
68 InflateRect(&Rect, -BorderSize, -BorderSize);
70
71 SelectObject(hDC, hbmData);
74 Failed |= ImageList_Add(hIL, hbmData, hbmMask) < 0;
76 Failed |= ImageList_Add(hIL, hbmData, hbmMask) < 0;
78 Failed |= ImageList_Add(hIL, hbmData, hbmMask) < 0;
80 Failed |= ImageList_Add(hIL, hbmData, hbmMask) < 0;
81
82 // Create the radio images
83 SelectObject(hDC, hbmMask);
84 SetRect(&Rect, 0, 0, ImageSize, ImageSize);
86 InflateRect(&Rect, -BorderSize, -BorderSize);
88
89 SelectObject(hDC, hbmData);
92 Failed |= ImageList_Add(hIL, hbmData, hbmMask) < 0;
94 Failed |= ImageList_Add(hIL, hbmData, hbmMask) < 0;
96 Failed |= ImageList_Add(hIL, hbmData, hbmMask) < 0;
98 Failed |= ImageList_Add(hIL, hbmData, hbmMask) < 0;
99
100 SelectObject(hDC, hbmOld);
101 DeleteObject(hbmMask);
102 DeleteObject(hbmData);
103 DeleteDC(hDC);
104 if (Failed)
105 {
107 hIL = NULL;
108 }
109 return hIL;
110}
#define FALSE
Definition: types.h:117
INT WINAPI ImageList_Add(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
Definition: imagelist.c:458
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:941
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:814
pKey DeleteObject()
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define ILC_MASK
Definition: commctrl.h:351
static HBITMAP CreatDibBitmap(HDC hDC, UINT cx, UINT cy, UINT bpp)
@ Failed
Definition: arc.h:79
#define max(a, b)
Definition: svc.c:63
int32_t INT
Definition: typedefs.h:58
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define WHITE_BRUSH
Definition: wingdi.h:902
#define BLACK_BRUSH
Definition: wingdi.h:896
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define DFCS_FLAT
Definition: winuser.h:510
#define DFCS_BUTTONCHECK
Definition: winuser.h:496
#define DFCS_INACTIVE
Definition: winuser.h:502
#define DFC_BUTTON
Definition: winuser.h:476
#define DFCS_MONO
Definition: winuser.h:511
#define DFCS_BUTTONRADIOMASK
Definition: winuser.h:498
#define DFCS_BUTTONRADIOIMAGE
Definition: winuser.h:497
#define DFCS_CHECKED
Definition: winuser.h:504
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by CRegTreeOptions::InitTree().

◆ GetDefaultValue()

static HRESULT GetDefaultValue ( HKEY  hKey,
DWORD Type,
LPVOID  Data,
DWORD Size 
)
static

Definition at line 160 of file regtreeoptions.cpp.

161{
162 DWORD Err = SHRegGetValueW(hKey, NULL, L"DefaultValue", SRRF_RT_ANY, &Type, Data, &Size);
163 return HRESULT_FROM_WIN32(Err);
164}
Type
Definition: Type.h:7
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
LSTATUS WINAPI SHRegGetValueW(_In_ HKEY hkey, _In_opt_ LPCWSTR pszSubKey, _In_opt_ LPCWSTR pszValue, _In_ SRRF srrfFlags, _Out_opt_ LPDWORD pdwType, _Out_writes_bytes_to_opt_(*pcbData, *pcbData) LPVOID pvData, _Inout_opt_ LPDWORD pcbData)
#define SRRF_RT_ANY
Definition: shlwapi.h:260
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

Referenced by CRegTreeOptions::GetCheckState(), and CRegTreeOptions::GetSetState().

◆ GetRegDWORD() [1/2]

static DWORD GetRegDWORD ( HKEY  hKey,
LPCWSTR  Name,
DWORD  Default 
)
static

Definition at line 128 of file regtreeoptions.cpp.

129{
130 DWORD Data = Default, Size = sizeof(Data);
132 return Err ? Default : Data;
133}
@ Default
Definition: stdole2.idl:392
#define SRRF_RT_DWORD
Definition: shlwapi.h:258

◆ GetRegDWORD() [2/2]

static DWORD GetRegDWORD ( HKEY  hKey,
LPCWSTR  Name,
PDWORD  Data 
)
inlinestatic

Definition at line 122 of file regtreeoptions.cpp.

123{
124 DWORD Size = sizeof(*Data);
126}

Referenced by CRegTreeOptions::AddItemsFromRegistry(), and CRegTreeOptions::GetSetState().

◆ GetRegString()

static HRESULT GetRegString ( HKEY  hKey,
LPCWSTR  Name,
LPWSTR  Buffer,
DWORD  cchBuffer 
)
static

Definition at line 135 of file regtreeoptions.cpp.

136{
137 DWORD Size = cchBuffer * sizeof(*Buffer);
139 return Err ? HRESULT_FROM_WIN32(Err) : Size / sizeof(*Buffer);
140}
Definition: bufpool.h:45
static DWORD cchBuffer
Definition: fusion.c:85
#define SRRF_RT_REG_SZ
Definition: shlwapi.h:251
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by AddIconFromRegistry().

◆ NormalizeRegType()

static DWORD NormalizeRegType ( DWORD  Type)
inlinestatic

Definition at line 112 of file regtreeoptions.cpp.

113{
114 switch (Type)
115 {
116 case REG_EXPAND_SZ: return REG_SZ;
117 case REG_DWORD: return REG_BINARY;
118 default: return Type;
119 }
120}
#define REG_SZ
Definition: layer.c:22
#define REG_BINARY
Definition: nt_native.h:1496
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by CRegTreeOptions::GetCheckState().