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
10
WINE_DEFAULT_DEBUG_CHANNEL
(shell_ad);
11
12
void
CFontFolderViewCB::Initialize
(
CFontExt
* pFontExt,
IShellView
*psv,
LPCITEMIDLIST
pidlParent)
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
24
HRESULT
CFontFolderViewCB::TranslatePidl
(
LPITEMIDLIST
* ppidlNew,
LPCITEMIDLIST
pidl)
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);
36
if
(
FAILED_UNEXPECTEDLY
(
hr
))
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
52
void
CFontFolderViewCB::TranslateTwoPIDLs
(
PIDLIST_ABSOLUTE
* pidls)
53
{
54
ATLASSERT
(pidls);
55
56
HRESULT
hr
;
57
if
(pidls[0])
58
{
59
m_pidl0
.Free();
60
hr
=
TranslatePidl
(&
m_pidl0
, pidls[0]);
61
if
(!
FAILED_UNEXPECTEDLY
(
hr
))
62
pidls[0] =
m_pidl0
;
63
}
64
if
(pidls[1])
65
{
66
m_pidl1
.Free();
67
hr
=
TranslatePidl
(&
m_pidl1
, pidls[1]);
68
if
(!
FAILED_UNEXPECTEDLY
(
hr
))
69
pidls[1] =
m_pidl1
;
70
}
71
}
72
73
BOOL
CFontFolderViewCB::FilterEvent
(
LONG
lEvent
)
const
74
{
75
switch
(
lEvent
& ~
SHCNE_INTERRUPT
)
76
{
77
case
SHCNE_CREATE
:
78
case
SHCNE_DELETE
:
79
case
SHCNE_RENAMEITEM
:
80
case
SHCNE_UPDATEDIR
:
81
return
FALSE
;
// OK
82
default
:
83
return
TRUE
;
// We don't want this event
84
}
85
}
86
87
STDMETHODIMP
88
CFontFolderViewCB::MessageSFVCB
(
UINT
uMsg,
WPARAM
wParam
,
LPARAM
lParam
)
89
{
90
switch
(uMsg)
91
{
92
case
SFVM_QUERYFSNOTIFY
:
// Registering change notification
93
{
94
// Now, we can get the view window
95
ATLASSERT
(
m_pShellView
);
96
ATLASSERT
(
m_pFontExt
);
97
m_pShellView
->
GetWindow
(&
m_hwndView
);
98
m_pFontExt
->
SetViewWindow
(
m_hwndView
);
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
106
TranslateTwoPIDLs
((
PIDLIST_ABSOLUTE
*)
wParam
);
107
return
S_OK
;
108
}
109
}
110
return
E_NOTIMPL
;
111
}
ATLASSERT
#define ATLASSERT(x)
Definition:
CComVariant.cpp:10
WINE_DEFAULT_DEBUG_CHANNEL
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition:
precomp.h:23
ERR
#define ERR(fmt,...)
Definition:
precomp.h:57
STDMETHODIMP
#define STDMETHODIMP
Definition:
basetyps.h:43
ATL::CStringT
Definition:
cstringt.h:419
CFontExt
Definition:
CFontExt.hpp:17
CFontExt::SetViewWindow
void SetViewWindow(HWND hwndView)
Definition:
CFontExt.hpp:29
CFontFolderViewCB::m_hwndView
HWND m_hwndView
Definition:
CFontFolderViewCB.h:16
CFontFolderViewCB::Initialize
void Initialize(CFontExt *pFontExt, IShellView *psv, LPCITEMIDLIST pidlParent)
Definition:
CFontFolderViewCB.cpp:12
CFontFolderViewCB::TranslatePidl
HRESULT TranslatePidl(LPITEMIDLIST *ppidlNew, LPCITEMIDLIST pidl)
Definition:
CFontFolderViewCB.cpp:24
CFontFolderViewCB::FilterEvent
BOOL FilterEvent(LONG lEvent) const
Definition:
CFontFolderViewCB.cpp:73
CFontFolderViewCB::m_pidl0
CComHeapPtr< ITEMIDLIST > m_pidl0
Definition:
CFontFolderViewCB.h:18
CFontFolderViewCB::MessageSFVCB
STDMETHOD() MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam) override
Definition:
CFontFolderViewCB.cpp:88
CFontFolderViewCB::m_pidl1
CComHeapPtr< ITEMIDLIST > m_pidl1
Definition:
CFontFolderViewCB.h:19
CFontFolderViewCB::m_pidlParent
CComHeapPtr< ITEMIDLIST > m_pidlParent
Definition:
CFontFolderViewCB.h:17
CFontFolderViewCB::TranslateTwoPIDLs
void TranslateTwoPIDLs(PIDLIST_ABSOLUTE *pidls)
Definition:
CFontFolderViewCB.cpp:52
CFontFolderViewCB::m_pShellView
IShellView * m_pShellView
Definition:
CFontFolderViewCB.h:15
CFontFolderViewCB::m_pFontExt
CFontExt * m_pFontExt
Definition:
CFontFolderViewCB.h:14
wParam
WPARAM wParam
Definition:
combotst.c:138
lParam
LPARAM lParam
Definition:
combotst.c:139
E_OUTOFMEMORY
#define E_OUTOFMEMORY
Definition:
ddrawi.h:100
E_NOTIMPL
#define E_NOTIMPL
Definition:
ddrawi.h:99
E_FAIL
#define E_FAIL
Definition:
ddrawi.h:102
NULL
#define NULL
Definition:
types.h:112
TRUE
#define TRUE
Definition:
types.h:120
FALSE
#define FALSE
Definition:
types.h:117
MAX_PATH
#define MAX_PATH
Definition:
compat.h:34
FAILED_UNEXPECTEDLY
#define FAILED_UNEXPECTEDLY
Definition:
utils.cpp:30
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
DoGetFontTitle
HRESULT DoGetFontTitle(_In_ LPCWSTR pszFontPath, _Out_ CStringW &strFontName)
Definition:
fontext.cpp:239
_ILCreate
LPITEMIDLIST _ILCreate(LPCWSTR lpString)
Definition:
fontpidl.cpp:10
HRESULT
Definition:
mshtmhst.idl:286
IOleWindow::GetWindow
HRESULT GetWindow([out] HWND *phwnd)
IShellView
Definition:
shobjidl.idl:724
S_OK
#define S_OK
Definition:
intsafe.h:52
LPARAM
LONG_PTR LPARAM
Definition:
minwindef.h:175
WPARAM
UINT_PTR WPARAM
Definition:
minwindef.h:174
UINT
unsigned int UINT
Definition:
ndis.h:50
LONG
long LONG
Definition:
pedump.c:60
ILClone
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition:
pidl.c:238
ILFree
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition:
pidl.c:1051
ILCombine
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition:
pidl.c:817
SHGetPathFromIDListW
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition:
pidl.c:1496
hr
HRESULT hr
Definition:
shlfolder.c:183
SHCNE_DELETE
#define SHCNE_DELETE
Definition:
shlobj.h:1897
SHCNE_RENAMEITEM
#define SHCNE_RENAMEITEM
Definition:
shlobj.h:1895
SHCNE_UPDATEDIR
#define SHCNE_UPDATEDIR
Definition:
shlobj.h:1907
SHCNE_CREATE
#define SHCNE_CREATE
Definition:
shlobj.h:1896
SFVM_FSNOTIFY
#define SFVM_FSNOTIFY
Definition:
shlobj.h:1312
SFVM_QUERYFSNOTIFY
#define SFVM_QUERYFSNOTIFY
Definition:
shlobj.h:1321
SHCNE_INTERRUPT
#define SHCNE_INTERRUPT
Definition:
shlobj.h:1920
LPITEMIDLIST
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition:
shtypes.idl:41
LPCITEMIDLIST
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition:
shtypes.idl:42
_ITEMIDLIST_ABSOLUTE
Definition:
shtypes.idl:46
lEvent
HANDLE lEvent
Definition:
tftpd.cpp:56
precomp.h
S_FALSE
#define S_FALSE
Definition:
winerror.h:3451
WCHAR
__wchar_t WCHAR
Definition:
xmlstorage.h:180
dll
shellext
fontext
CFontFolderViewCB.cpp
Generated on Tue Jan 20 2026 06:03:59 for ReactOS by
1.9.6