xref: /reactos/dll/win32/shdocvw/CFavBand.h (revision a8b33400)
1 /*
2  * PROJECT:     ReactOS Explorer
3  * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4  * PURPOSE:     Favorites bar
5  * COPYRIGHT:   Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6  */
7 
8 #pragma once
9 
10 EXTERN_C VOID CFavBand_Init(HINSTANCE hInstance);
11 EXTERN_C HRESULT CFavBand_DllCanUnloadNow(VOID);
12 EXTERN_C HRESULT CFavBand_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv);
13 EXTERN_C HRESULT CFavBand_DllRegisterServer(VOID);
14 EXTERN_C HRESULT CFavBand_DllUnregisterServer(VOID);
15 
16 #define FAVBANDCLASSNAME L"ReactOS Favorites Band"
17 
18 #ifdef __cplusplus
19 class CFavBand
20     : public CComCoClass<CFavBand, &CLSID_SH_FavBand>
21     , public CComObjectRootEx<CComMultiThreadModelNoCS>
22     , public CWindowImpl<CFavBand>
23     , public IDispatch
24     , public IDeskBand
25     , public IObjectWithSite
26     , public IInputObject
27     , public IPersistStream
28     , public IOleCommandTarget
29     , public IServiceProvider
30     , public IContextMenu
31     , public IBandNavigate
32     , public IWinEventHandler
33     , public INamespaceProxy
34 {
35 public:
36     DECLARE_WND_CLASS_EX(FAVBANDCLASSNAME, 0, COLOR_3DFACE)
37     static LPCWSTR GetWndClassName() { return FAVBANDCLASSNAME; }
38 
39     CFavBand();
40     virtual ~CFavBand();
41 
42     // *** IOleWindow methods ***
43     STDMETHODIMP GetWindow(HWND *lphwnd) override;
44     STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode) override;
45 
46     // *** IDockingWindow methods ***
47     STDMETHODIMP CloseDW(DWORD dwReserved) override;
48     STDMETHODIMP ResizeBorderDW(const RECT *prcBorder, IUnknown *punkToolbarSite, BOOL fReserved) override;
49     STDMETHODIMP ShowDW(BOOL fShow) override;
50 
51     // *** IDeskBand methods ***
52     STDMETHODIMP GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi) override;
53 
54     // *** IObjectWithSite methods ***
55     STDMETHODIMP SetSite(IUnknown *pUnkSite) override;
56     STDMETHODIMP GetSite(REFIID riid, void **ppvSite) override;
57 
58     // *** IOleCommandTarget methods ***
59     STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD prgCmds [], OLECMDTEXT *pCmdText) override;
60     STDMETHODIMP Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut) override;
61 
62     // *** IServiceProvider methods ***
63     STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void **ppvObject) override;
64 
65     // *** IContextMenu methods ***
66     STDMETHODIMP QueryContextMenu(
67         HMENU hmenu,
68         UINT indexMenu,
69         UINT idCmdFirst,
70         UINT idCmdLast,
71         UINT uFlags) override;
72     STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpici) override;
73     STDMETHODIMP GetCommandString(
74         UINT_PTR idCmd,
75         UINT uType,
76         UINT *pwReserved,
77         LPSTR pszName,
78         UINT cchMax) override;
79 
80     // *** IInputObject methods ***
81     STDMETHODIMP UIActivateIO(BOOL fActivate, LPMSG lpMsg) override;
82     STDMETHODIMP HasFocusIO() override;
83     STDMETHODIMP TranslateAcceleratorIO(LPMSG lpMsg) override;
84 
85     // *** IPersist methods ***
86     STDMETHODIMP GetClassID(CLSID *pClassID) override;
87 
88     // *** IPersistStream methods ***
89     STDMETHODIMP IsDirty() override;
90     STDMETHODIMP Load(IStream *pStm) override;
91     STDMETHODIMP Save(IStream *pStm, BOOL fClearDirty) override;
92     STDMETHODIMP GetSizeMax(ULARGE_INTEGER *pcbSize) override;
93 
94     // *** IWinEventHandler methods ***
95     STDMETHODIMP OnWinEvent(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *theResult) override;
96     STDMETHODIMP IsWindowOwner(HWND hWnd) override;
97 
98     // *** IBandNavigate methods ***
99     STDMETHODIMP Select(long paramC) override;
100 
101     // *** INamespaceProxy methods ***
102     STDMETHODIMP GetNavigateTarget(
103         _In_ PCIDLIST_ABSOLUTE pidl,
104         _Out_ PIDLIST_ABSOLUTE ppidlTarget,
105         _Out_ ULONG *pulAttrib) override;
106     STDMETHODIMP Invoke(_In_ PCIDLIST_ABSOLUTE pidl) override;
107     STDMETHODIMP OnSelectionChanged(_In_ PCIDLIST_ABSOLUTE pidl) override;
108     STDMETHODIMP RefreshFlags(
109         _Out_ DWORD *pdwStyle,
110         _Out_ DWORD *pdwExStyle,
111         _Out_ DWORD *dwEnum) override;
112     STDMETHODIMP CacheItem(_In_ PCIDLIST_ABSOLUTE pidl) override;
113 
114     // *** IDispatch methods ***
115     STDMETHODIMP GetTypeInfoCount(UINT *pctinfo) override;
116     STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) override;
117     STDMETHODIMP GetIDsOfNames(
118         REFIID riid,
119         LPOLESTR *rgszNames,
120         UINT cNames,
121         LCID lcid,
122         DISPID *rgDispId) override;
123     STDMETHODIMP Invoke(
124         DISPID dispIdMember,
125         REFIID riid,
126         LCID lcid,
127         WORD wFlags,
128         DISPPARAMS *pDispParams,
129         VARIANT *pVarResult,
130         EXCEPINFO *pExcepInfo,
131         UINT *puArgErr) override;
132 
133     DECLARE_REGISTRY_RESOURCEID(IDR_FAVBAND)
134     DECLARE_NOT_AGGREGATABLE(CFavBand)
135     DECLARE_PROTECT_FINAL_CONSTRUCT()
136 
137     BEGIN_COM_MAP(CFavBand)
138         COM_INTERFACE_ENTRY_IID(IID_IDispatch, IDispatch)
139         COM_INTERFACE_ENTRY_IID(IID_IDeskBand, IDeskBand)
140         COM_INTERFACE_ENTRY2_IID(IID_IDockingWindow, IDockingWindow, IDeskBand)
141         COM_INTERFACE_ENTRY2_IID(IID_IOleWindow, IOleWindow, IDeskBand)
142         COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite)
143         COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject)
144         COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream)
145         COM_INTERFACE_ENTRY2_IID(IID_IPersist, IPersist, IPersistStream)
146         COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
147         COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
148         COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu)
149         COM_INTERFACE_ENTRY2_IID(IID_IUnknown, IUnknown, IContextMenu)
150         COM_INTERFACE_ENTRY_IID(IID_IBandNavigate, IBandNavigate)
151         COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler, IWinEventHandler)
152         COM_INTERFACE_ENTRY_IID(IID_INamespaceProxy, INamespaceProxy)
153     END_COM_MAP()
154 
155     BEGIN_MSG_MAP(CFavBand)
156         MESSAGE_HANDLER(WM_CREATE, OnCreate)
157         MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
158         MESSAGE_HANDLER(WM_SIZE, OnSize)
159         MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
160         MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
161         MESSAGE_HANDLER(WM_COMMAND, OnCommand)
162     END_MSG_MAP()
163 
164 protected:
165     BOOL m_fVisible;
166     BOOL m_bFocused;
167     DWORD m_dwBandID;
168     CComPtr<IUnknown> m_pSite;
169     CComHeapPtr<ITEMIDLIST> m_pidlFav;
170     HIMAGELIST m_hToolbarImageList;
171     HIMAGELIST m_hTreeViewImageList;
172     CToolbar<> m_hwndToolbar;
173     CTreeView m_hwndTreeView;
174 
175     VOID OnFinalMessage(HWND) override;
176 
177     // *** helper methods ***
178     BOOL CreateToolbar();
179     BOOL CreateTreeView();
180 
181     // *** message handlers ***
182     LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
183     LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
184     LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
185     LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
186     LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
187     LRESULT OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled);
188 };
189 #endif // def __cplusplus
190