ReactOS 0.4.16-dev-1255-g6dd0406
CRegTreeOptions Class Reference

#include <regtreeoptions.h>

Inheritance diagram for CRegTreeOptions:
Collaboration diagram for CRegTreeOptions:

Public Member Functions

 CRegTreeOptions ()
 
 ~CRegTreeOptions ()
 
void AddItemsFromRegistry (HKEY hKey, HTREEITEM hParent, HTREEITEM hInsertAfter)
 
STDMETHOD() InitTree (HWND hTV, HKEY hKey, LPCSTR SubKey, char const *pUnknown) override
 
STDMETHOD() WalkTree (WALK_TREE_CMD Command) override
 
STDMETHOD() ToggleItem (HTREEITEM hTI) override
 
STDMETHOD() ShowHelp (HTREEITEM hTI, unsigned long Unknown) override
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 

Private Attributes

HWND m_hTree
 
HIMAGELIST m_hIL
 

Additional Inherited Members

- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Detailed Description

Definition at line 10 of file regtreeoptions.h.

Constructor & Destructor Documentation

◆ CRegTreeOptions()

CRegTreeOptions::CRegTreeOptions ( )

Definition at line 404 of file regtreeoptions.cpp.

405{
406 m_hTree = NULL;
407 m_hIL = NULL;
408}
HIMAGELIST m_hIL
#define NULL
Definition: types.h:112

◆ ~CRegTreeOptions()

CRegTreeOptions::~CRegTreeOptions ( )

Definition at line 410 of file regtreeoptions.cpp.

411{
412 if (m_hIL && m_hTree)
414}
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:941
#define TVSIL_NORMAL
Definition: commctrl.h:3448
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3452

Member Function Documentation

◆ AddItemsFromRegistry()

void CRegTreeOptions::AddItemsFromRegistry ( HKEY  hKey,
HTREEITEM  hParent,
HTREEITEM  hInsertAfter 
)

Definition at line 416 of file regtreeoptions.cpp.

417{
418 for (DWORD Index = 0, cchName;;)
419 {
420 WCHAR Name[MAX_PATH], Temp[MAX_PATH];
423 break;
424
425 HKEY hItemKey, hCloseKey = NULL;
426 if (RegOpenKeyExW(hKey, Name, 0, KEY_READ, &hItemKey) != ERROR_SUCCESS)
427 continue;
428
429 TVINSERTSTRUCT tvis;
430 TVITEM &tvi = tvis.item;
432 tvi.lParam = (LPARAM)hItemKey;
434 if (GetRegString(hItemKey, L"Type", Temp, _countof(Temp)) > 0)
435 {
436 if (!lstrcmpi(Temp, L"checkbox"))
438 if (!lstrcmpi(Temp, L"radio"))
440 if (!lstrcmpi(Temp, L"group"))
442 }
443 BOOL Valid = Type != TYPE_INVALID;
444
445 if (Type == TYPE_GROUP)
446 {
447 tvi.lParam = 0;
448 hCloseKey = hItemKey;
449 tvi.iImage = AddIconFromRegistry(m_hIL, hItemKey, L"Bitmap");
450 }
451 else if (Valid)
452 {
453 HRESULT hr = GetCheckState(hItemKey);
454 Valid = SUCCEEDED(hr);
455 tvi.iImage = (Type * STATEIMAGESPERTYPE) | (hr == S_OK);
456 }
457
458 if (Valid)
459 {
460 if (SUCCEEDED(SHLoadRegUIStringW(hItemKey, L"Text", Temp, _countof(Temp))))
461 tvi.pszText = Temp;
462 else
463 tvi.pszText = Name;
464#ifdef __REACTOS__ // Grayed is a ROS extension
465 DWORD grayed = GetRegDWORD(hItemKey, L"Grayed", DWORD(FALSE));
466 if (grayed)
467 {
468 tvi.lParam = (LPARAM)HKEY_GRAYED;
469 hCloseKey = hItemKey;
470 tvi.iImage += 2; // Use disabled state image
471 if (grayed & 4)
472 tvi.iImage = (tvi.iImage & ~1) | ((grayed & 2) != 0); // Force a specific state
473 }
474#endif
475 tvi.iSelectedImage = tvi.iImage;
476 tvis.hParent = hParent;
477 tvis.hInsertAfter = hInsertAfter;
478 Valid = (tvi.hItem = TreeView_InsertItem(m_hTree, &tvis)) != NULL;
479 }
480
481 if (Valid && Type == TYPE_GROUP)
482 {
483 AddItemsFromRegistry(hItemKey, tvi.hItem, TVI_FIRST);
485 }
486 if (!Valid)
487 RegCloseKey(hItemKey);
488 if (hCloseKey && hItemKey != hCloseKey)
489 RegCloseKey(hCloseKey);
490 }
492}
Type
Definition: Type.h:7
LPCWSTR GetRegString(CRegKey &Key, LPCWSTR Name, CStringW &Value)
Definition: misc.cpp:464
#define RegCloseKey(hKey)
Definition: registry.h:49
void AddItemsFromRegistry(HKEY hKey, HTREEITEM hParent, HTREEITEM hInsertAfter)
#define ERROR_SUCCESS
Definition: deptool.c:10
LPWSTR Name
Definition: desk.c:124
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
#define MAX_PATH
Definition: compat.h:34
HRESULT WINAPI SHLoadRegUIStringW(HKEY hkey, LPCWSTR value, LPWSTR buf, DWORD size)
Definition: ordinal.c:4277
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
unsigned int UINT
Definition: ndis.h:50
#define KEY_READ
Definition: nt_native.h:1023
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
#define TVITEM
Definition: commctrl.h:3370
#define TVIF_TEXT
Definition: commctrl.h:3271
#define TreeView_Expand(hwnd, hitem, code)
Definition: commctrl.h:3425
#define TVINSERTSTRUCT
Definition: commctrl.h:3407
#define TVIF_IMAGE
Definition: commctrl.h:3272
#define TVI_FIRST
Definition: commctrl.h:3374
#define TVE_EXPAND
Definition: commctrl.h:3428
#define TVM_SORTCHILDREN
Definition: commctrl.h:3546
#define TVIF_PARAM
Definition: commctrl.h:3273
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3417
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3276
static int AddIconFromRegistry(HIMAGELIST hIL, HKEY hKey, LPCWSTR Name)
@ TYPE_RADIO
@ TYPE_CHECK
@ STATEIMAGESPERTYPE
@ TYPE_GROUP
@ TYPE_INVALID
#define HKEY_GRAYED
static HRESULT GetCheckState(HKEY hKey, BOOL UseDefault=FALSE)
static DWORD GetRegDWORD(HKEY hKey, LPCWSTR Name, PDWORD Data)
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: sndvol32.h:70
_In_ WDFCOLLECTION _In_ ULONG Index
#define lstrcmpi
Definition: winbase.h:3914
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2808
LONG_PTR LPARAM
Definition: windef.h:208
#define SendMessage
Definition: winuser.h:5928
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by AddItemsFromRegistry(), and InitTree().

◆ InitTree()

HRESULT STDMETHODCALLTYPE CRegTreeOptions::InitTree ( HWND  hTV,
HKEY  hKey,
LPCSTR  SubKey,
char const pUnknown 
)
override

Definition at line 494 of file regtreeoptions.cpp.

495{
497 m_hTree = hTV;
498
501 if (hIL)
503
507 {
510 }
511
513 return E_NOTIMPL;
514}
PRTL_UNICODE_STRING_BUFFER Path
#define E_NOTIMPL
Definition: ddrawi.h:99
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2673
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define TreeView_EnsureVisible(hwnd, hitem)
Definition: commctrl.h:3550
#define TVI_ROOT
Definition: commctrl.h:3373
#define TreeView_GetRoot(hwnd)
Definition: commctrl.h:3480
static HIMAGELIST CreateStateImages(UINT ImageSize)
#define SM_CXSMICON
Definition: winuser.h:1023
int WINAPI GetSystemMetrics(_In_ int)

◆ ShowHelp()

HRESULT STDMETHODCALLTYPE CRegTreeOptions::ShowHelp ( HTREEITEM  hTI,
unsigned long  Unknown 
)
override

Definition at line 566 of file regtreeoptions.cpp.

567{
568 return E_NOTIMPL;
569}

◆ ToggleItem()

HRESULT STDMETHODCALLTYPE CRegTreeOptions::ToggleItem ( HTREEITEM  hTI)
override

Definition at line 526 of file regtreeoptions.cpp.

527{
528 TVITEM tvi;
530 tvi.hItem = hTI;
531 if (!tvi.hItem || !TreeView_GetItem(m_hTree, &tvi))
532 return E_INVALIDARG;
533
534 if (tvi.iImage >= STATE_GROUP || (HKEY)tvi.lParam == HKEY_GRAYED)
535 return S_FALSE;
536
537 if (tvi.iImage <= max(STATE_CHECKOFF, STATE_CHECKON))
538 {
539 tvi.iImage ^= 1;
540 }
541 else
542 {
544 while (hRadio) // Turn off everyone in this group
545 {
546 tvi.hItem = hRadio;
547 tvi.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
548 if (TreeView_GetItem(m_hTree, &tvi) && tvi.iImage == STATE_RADIOON && hRadio != hTI)
549 {
550 tvi.iImage ^= 1;
551 tvi.iSelectedImage = tvi.iImage;
553 }
554 hRadio = TreeView_GetNextSibling(m_hTree, hRadio);
555 }
556 tvi.iImage = STATE_RADIOON;
557 }
558
559 tvi.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
560 tvi.hItem = hTI;
561 tvi.iSelectedImage = tvi.iImage;
563 return S_OK;
564}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3471
#define TreeView_GetParent(hwnd, hitem)
Definition: commctrl.h:3474
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3495
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3472
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3502
@ STATE_CHECKON
@ STATE_RADIOON
@ STATE_CHECKOFF
@ STATE_GROUP
int iSelectedImage
Definition: treeview.c:148
#define max(a, b)
Definition: svc.c:63
#define S_FALSE
Definition: winerror.h:2357

◆ WalkTree()

HRESULT STDMETHODCALLTYPE CRegTreeOptions::WalkTree ( WALK_TREE_CMD  Command)
override

Definition at line 516 of file regtreeoptions.cpp.

517{
518 for (HTREEITEM hTI = TreeView_GetRoot(m_hTree); hTI;)
519 {
522 }
523 return S_OK;
524}
STDMETHOD() WalkTree(WALK_TREE_CMD Command) override
Definition: shell.h:41

Referenced by WalkTree().

Member Data Documentation

◆ m_hIL

HIMAGELIST CRegTreeOptions::m_hIL
private

Definition at line 18 of file regtreeoptions.h.

Referenced by AddItemsFromRegistry(), CRegTreeOptions(), InitTree(), and ~CRegTreeOptions().

◆ m_hTree

HWND CRegTreeOptions::m_hTree
private

The documentation for this class was generated from the following files: