1 /*
2  * PROJECT:     ReactOS Compatibility Layer Shell Extension
3  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE:     CLayerUIPropPage definition
5  * COPYRIGHT:   Copyright 2015-2019 Mark Jansen (mark.jansen@reactos.org)
6  */
7 
8 #pragma once
9 
10 class CLayerUIPropPage :
11     public CPropertyPageImpl<CLayerUIPropPage>,
12     public CComCoClass<CLayerUIPropPage, &CLSID_CLayerUIPropPage>,
13     public CComObjectRootEx<CComMultiThreadModelNoCS>,
14     public IShellExtInit,
15     public IShellPropSheetExt
16 {
17 public:
18     CSimpleArray<CString> m_CustomLayers;
19 
20     CLayerUIPropPage();
21     ~CLayerUIPropPage();
22 
23     // IShellExtInit
24     STDMETHODIMP Initialize(PCIDLIST_ABSOLUTE pidlFolder, LPDATAOBJECT pdtobj, HKEY hkeyProgID);
25 
26 
27     // IShellPropSheetExt
28     STDMETHODIMP AddPages(LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
29     {
30         HPROPSHEETPAGE hPage = Create();
31         if (hPage && !pfnAddPage(hPage, lParam))
32             DestroyPropertySheetPage(hPage);
33 
34         return S_OK;
35     }
36 
37     STDMETHODIMP ReplacePage(UINT, LPFNADDPROPSHEETPAGE, LPARAM)
38     {
39         return E_NOTIMPL;
40     }
41 
42     VOID OnPageAddRef()
43     {
44         InterlockedIncrement(&g_ModuleRefCnt);
45     }
46 
47     VOID OnPageRelease()
48     {
49         InterlockedDecrement(&g_ModuleRefCnt);
50     }
51 
52     HRESULT InitFile(PCWSTR Filename);
53     void UpdateControls();
54     INT_PTR DisableControls();
55     BOOL HasChanges() const;
56 
57     int OnSetActive();
58     int OnApply();
59     LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
60     LRESULT OnCtrlCommand(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
61     LRESULT OnEditModes(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled);
62     LRESULT OnClickNotify(INT uCode, LPNMHDR hdr, BOOL& bHandled);
63 
64 protected:
65     CString m_Filename;
66     BOOL m_IsSfcProtected;
67     BOOL m_AllowPermLayer;
68     DWORD m_LayerQueryFlags;
69     DWORD m_RegistryOSMode, m_OSMode;
70     DWORD m_RegistryEnabledLayers, m_EnabledLayers;
71     CSimpleArray<CString> m_RegistryCustomLayers;
72 
73 public:
74     enum { IDD = IDD_ACPPAGESHEET };
75 
76     BEGIN_MSG_MAP(CLayerUIPropPage)
77         MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
78         COMMAND_RANGE_HANDLER(IDC_CHKRUNCOMPATIBILITY, IDC_CHKDISABLEVISUALTHEMES, OnCtrlCommand)
79         COMMAND_ID_HANDLER(IDC_EDITCOMPATIBILITYMODES, OnEditModes)
80         NOTIFY_CODE_HANDLER(NM_CLICK, OnClickNotify)
81         NOTIFY_CODE_HANDLER(NM_RETURN, OnClickNotify)
82         CHAIN_MSG_MAP(CPropertyPageImpl<CLayerUIPropPage>)
83     END_MSG_MAP()
84 
85     DECLARE_REGISTRY_RESOURCEID(IDR_ACPPAGE)
86     DECLARE_NOT_AGGREGATABLE(CLayerUIPropPage)
87 
88     DECLARE_PROTECT_FINAL_CONSTRUCT()
89 
90     BEGIN_COM_MAP(CLayerUIPropPage)
91         COM_INTERFACE_ENTRY_IID(IID_IShellExtInit, IShellExtInit)
92         COM_INTERFACE_ENTRY_IID(IID_IShellPropSheetExt, IShellPropSheetExt)
93     END_COM_MAP()
94 };
95