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