ReactOS 0.4.16-dev-2175-g9420ab7
CFontFolderViewCB.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Font Shell Extension
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Fonts folder view callback implementation
5 * COPYRIGHT: Copyright 2026 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8#include "precomp.h"
9
11
13{
14 ATLASSERT(pFontExt);
15 ATLASSERT(psv);
16 ATLASSERT(pidlParent);
17 m_pFontExt = pFontExt;
18 m_pShellView = psv;
19 m_pidlParent.Attach(ILClone(pidlParent));
20 if (!m_pidlParent)
21 ERR("!m_pidlParent\n");
22}
23
25{
26 ATLASSERT(ppidlNew);
27
28 *ppidlNew = NULL;
29
30 WCHAR szFontFile[MAX_PATH];
31 if (!SHGetPathFromIDListW(pidl, szFontFile))
32 return E_FAIL;
33
34 CStringW strFontName;
35 HRESULT hr = DoGetFontTitle(szFontFile, strFontName);
37 return E_FAIL;
38
39 LPITEMIDLIST pidlChild = _ILCreate(strFontName);
40 if (!pidlChild)
41 {
42 ERR("!pidlChild\n");
43 return E_OUTOFMEMORY;
44 }
45
46 *ppidlNew = ILCombine(m_pidlParent, pidlChild);
47 ILFree(pidlChild);
48
49 return *ppidlNew ? S_OK : E_OUTOFMEMORY;
50}
51
53{
54 ATLASSERT(pidls);
55
56 HRESULT hr;
57 if (pidls[0])
58 {
59 m_pidl0.Free();
60 hr = TranslatePidl(&m_pidl0, pidls[0]);
62 pidls[0] = m_pidl0;
63 }
64 if (pidls[1])
65 {
66 m_pidl1.Free();
67 hr = TranslatePidl(&m_pidl1, pidls[1]);
69 pidls[1] = m_pidl1;
70 }
71}
72
74{
75 switch (lEvent & ~SHCNE_INTERRUPT)
76 {
77 case SHCNE_CREATE:
78 case SHCNE_DELETE:
80 case SHCNE_UPDATEDIR:
81 return FALSE; // OK
82 default:
83 return TRUE; // We don't want this event
84 }
85}
86
89{
90 switch (uMsg)
91 {
92 case SFVM_QUERYFSNOTIFY: // Registering change notification
93 {
94 // Now, we can get the view window
99 return S_OK;
100 }
101 case SFVM_FSNOTIFY: // Change notification
102 {
103 if (FilterEvent((LONG)lParam))
104 return S_FALSE; // Don't process
105
107 return S_OK;
108 }
109 }
110 return E_NOTIMPL;
111}
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ERR(fmt,...)
Definition: precomp.h:57
#define STDMETHODIMP
Definition: basetyps.h:43
void SetViewWindow(HWND hwndView)
Definition: CFontExt.hpp:29
void Initialize(CFontExt *pFontExt, IShellView *psv, LPCITEMIDLIST pidlParent)
HRESULT TranslatePidl(LPITEMIDLIST *ppidlNew, LPCITEMIDLIST pidl)
BOOL FilterEvent(LONG lEvent) const
CComHeapPtr< ITEMIDLIST > m_pidl0
STDMETHOD() MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam) override
CComHeapPtr< ITEMIDLIST > m_pidl1
CComHeapPtr< ITEMIDLIST > m_pidlParent
void TranslateTwoPIDLs(PIDLIST_ABSOLUTE *pidls)
IShellView * m_pShellView
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:30
unsigned int BOOL
Definition: ntddk_ex.h:94
HRESULT DoGetFontTitle(_In_ LPCWSTR pszFontPath, _Out_ CStringW &strFontName)
Definition: fontext.cpp:239
LPITEMIDLIST _ILCreate(LPCWSTR lpString)
Definition: fontpidl.cpp:10
HRESULT GetWindow([out] HWND *phwnd)
#define S_OK
Definition: intsafe.h:52
LONG_PTR LPARAM
Definition: minwindef.h:175
UINT_PTR WPARAM
Definition: minwindef.h:174
unsigned int UINT
Definition: ndis.h:50
long LONG
Definition: pedump.c:60
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:238
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:817
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1496
HRESULT hr
Definition: shlfolder.c:183
#define SHCNE_DELETE
Definition: shlobj.h:1897
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1895
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1907
#define SHCNE_CREATE
Definition: shlobj.h:1896
#define SFVM_FSNOTIFY
Definition: shlobj.h:1312
#define SFVM_QUERYFSNOTIFY
Definition: shlobj.h:1321
#define SHCNE_INTERRUPT
Definition: shlobj.h:1920
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
HANDLE lEvent
Definition: tftpd.cpp:56
#define S_FALSE
Definition: winerror.h:3451
__wchar_t WCHAR
Definition: xmlstorage.h:180