ReactOS  0.4.15-dev-3163-gf17c2c0
CFontMenu.cpp File Reference
#include "precomp.h"
Include dependency graph for CFontMenu.cpp:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (fontext)
 
HRESULT _GetCidlFromDataObject (IDataObject *pDataObject, CIDA **ppcida)
 
const charDFM_TO_STR (UINT uMsg)
 
static void RunFontViewer (HWND hwnd, const FontPidlEntry *fontEntry)
 
static HRESULT CALLBACK FontFolderMenuCallback (IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
HRESULT _CFontMenu_CreateInstance (HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, REFIID riid, LPVOID *ppvOut)
 

Variables

static CLIPFORMAT g_cfHIDA
 

Function Documentation

◆ _CFontMenu_CreateInstance()

HRESULT _CFontMenu_CreateInstance ( HWND  hwnd,
UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
IShellFolder psf,
REFIID  riid,
LPVOID ppvOut 
)

Definition at line 146 of file CFontMenu.cpp.

148 {
149  if (cidl > 0)
150  {
151  HKEY keys[1] = {0};
152  int nkeys = 0;
153  CComPtr<IContextMenu> spMenu;
154 
155  // Use the default context menu handler, but augment it from the callbacks
156  HRESULT hr = CDefFolderMenu_Create2(NULL, hwnd, cidl, apidl, psf, FontFolderMenuCallback, nkeys, keys, &spMenu);
157 
158  if (FAILED_UNEXPECTEDLY(hr))
159  return hr;
160 
161  // See if the requested interface (e.g. IContextMenu3) is also available
162  return spMenu->QueryInterface(riid, ppvOut);
163  }
164 
165  // We can't create a background menu
166  return E_FAIL;
167 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
#define E_FAIL
Definition: ddrawi.h:102
static HRESULT CALLBACK FontFolderMenuCallback(IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CFontMenu.cpp:89
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
#define NULL
Definition: types.h:112
HRESULT WINAPI CDefFolderMenu_Create2(PCIDLIST_ABSOLUTE pidlFolder, HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, LPFNDFMCALLBACK lpfn, UINT nKeys, const HKEY *ahkeyClsKeys, IContextMenu **ppcm)

Referenced by CFontExt::GetUIObjectOf().

◆ _GetCidlFromDataObject()

HRESULT _GetCidlFromDataObject ( IDataObject pDataObject,
CIDA **  ppcida 
)

Definition at line 14 of file CFontMenu.cpp.

15 {
16  if (g_cfHIDA == NULL)
17  {
19  }
20 
21  FORMATETC fmt = { g_cfHIDA, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
22  STGMEDIUM medium;
23 
24  HRESULT hr = pDataObject->GetData(&fmt, &medium);
26  return hr;
27 
28  LPVOID lpSrc = GlobalLock(medium.hGlobal);
29  SIZE_T cbSize = GlobalSize(medium.hGlobal);
30 
31  *ppcida = (CIDA *)::CoTaskMemAlloc(cbSize);
32  if (*ppcida)
33  {
34  memcpy(*ppcida, lpSrc, cbSize);
35  hr = S_OK;
36  }
37  else
38  {
39  hr = E_FAIL;
40  }
41  ReleaseStgMedium(&medium);
42  return hr;
43 }
#define CFSTR_SHELLIDLIST
Definition: shlobj.h:477
HRESULT hr
Definition: shlfolder.c:183
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
static CLIPFORMAT g_cfHIDA
Definition: CFontMenu.cpp:12
#define E_FAIL
Definition: ddrawi.h:102
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
Definition: dsound.c:943
Definition: shlobj.h:498

Referenced by CMoveToMenu::DoGetFileTitle(), CMoveToMenu::DoRealMove(), CFontExt::DragEnter(), CFontExt::Drop(), and FontFolderMenuCallback().

◆ DFM_TO_STR()

const char* DFM_TO_STR ( UINT  uMsg)

Definition at line 45 of file CFontMenu.cpp.

46 {
47  switch(uMsg)
48  {
49  case DFM_MERGECONTEXTMENU: return "DFM_MERGECONTEXTMENU";
50  case DFM_INVOKECOMMAND: return "DFM_INVOKECOMMAND";
51  case DFM_MODIFYQCMFLAGS: return "DFM_MODIFYQCMFLAGS";
52  case DFM_MERGECONTEXTMENU_TOP: return "DFM_MERGECONTEXTMENU_TOP";
53  case DFM_MERGECONTEXTMENU_BOTTOM: return "DFM_MERGECONTEXTMENU_BOTTOM";
54  case DFM_GETHELPTEXTW: return "DFM_GETHELPTEXTW";
55  case DFM_GETVERBW: return "DFM_GETVERBW";
56  case DFM_GETVERBA: return "DFM_GETVERBA";
57  case DFM_WM_INITMENUPOPUP: return "DFM_WM_INITMENUPOPUP";
58  case DFM_INVOKECOMMANDEX: return "DFM_INVOKECOMMANDEX";
59  case DFM_GETDEFSTATICID: return "DFM_GETDEFSTATICID";
60  case 3: return "MENU_BEGIN";
61  case 4: return "MENU_END";
62  default: return "";
63  }
64 }
#define DFM_MERGECONTEXTMENU_BOTTOM
Definition: shlobj.h:2421
#define DFM_MODIFYQCMFLAGS
Definition: shlobj.h:2422
#define DFM_GETVERBW
Definition: shlobj.h:2419
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
#define DFM_WM_INITMENUPOPUP
Definition: shlobj.h:2414
#define DFM_GETHELPTEXTW
Definition: shlobj.h:2417
#define DFM_GETDEFSTATICID
Definition: precomp.h:47
#define DFM_MERGECONTEXTMENU
Definition: precomp.h:44
#define DFM_MERGECONTEXTMENU_TOP
Definition: shlobj.h:2416
#define DFM_INVOKECOMMANDEX
Definition: precomp.h:46
#define DFM_GETVERBA
Definition: shlobj.h:2420

Referenced by FontFolderMenuCallback().

◆ FontFolderMenuCallback()

static HRESULT CALLBACK FontFolderMenuCallback ( IShellFolder psf,
HWND  hwnd,
IDataObject pdtobj,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 89 of file CFontMenu.cpp.

91 {
92  TRACE("FontFolderMenuCallback(%u {%s})\n", uMsg, DFM_TO_STR(uMsg));
93  switch (uMsg)
94  {
96  {
97  QCMINFO *pqcminfo = (QCMINFO *)lParam;
98 
100  MENUITEMINFOW cmi = { sizeof(cmi) };
102  cmi.fType = MFT_STRING;
103  cmi.fState = MFS_DEFAULT;
104  cmi.wID = pqcminfo->idCmdFirst++;
105  cmi.dwTypeData = (LPWSTR)menuText.GetString();
106  InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu, TRUE, &cmi);
107 
108  return S_OK;
109  }
110  case DFM_INVOKECOMMAND:
111  // Preview is the only item we handle
112  if (wParam == 0)
113  {
114  CComHeapPtr<CIDA> cida;
115  HRESULT hr = _GetCidlFromDataObject(pdtobj, &cida);
116  if (FAILED_UNEXPECTEDLY(hr))
117  return hr;
118 
119  for (UINT n = 0; n < cida->cidl; ++n)
120  {
121  const FontPidlEntry* fontEntry = _FontFromIL(HIDA_GetPIDLItem(cida, n));
122  RunFontViewer(hwnd, fontEntry);
123  }
124  return S_OK;
125  }
126  else if (wParam == DFM_CMD_PROPERTIES)
127  {
128  ERR("Default properties handling!\n");
129  return S_FALSE;
130  }
131  else
132  {
133  ERR("Unhandled DFM_INVOKECOMMAND(wParam=0x%x)\n", wParam);
134  }
135  return S_FALSE;
136 
137  case DFM_INVOKECOMMANDEX:
138  return E_NOTIMPL;
139  case DFM_GETDEFSTATICID: // Required for Windows 7 to pick a default
140  return S_FALSE;
141  }
142  return E_NOTIMPL;
143 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MFT_STRING
Definition: winuser.h:741
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const *pida, SIZE_T i)
Definition: shellutils.h:554
HMENU hmenu
Definition: shlobj.h:1315
GLdouble n
Definition: glext.h:7729
const FontPidlEntry * _FontFromIL(LPCITEMIDLIST pidl)
Definition: fontpidl.cpp:32
HRESULT _GetCidlFromDataObject(IDataObject *pDataObject, CIDA **ppcida)
Definition: CFontMenu.cpp:14
LPWSTR dwTypeData
Definition: winuser.h:3245
#define MFS_DEFAULT
Definition: winuser.h:743
WPARAM wParam
Definition: combotst.c:138
#define MIIM_STATE
Definition: winuser.h:716
#define S_FALSE
Definition: winerror.h:2357
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
UINT indexMenu
Definition: shlobj.h:1316
#define MIIM_ID
Definition: winuser.h:717
#define TRACE(s)
Definition: solgame.cpp:4
#define DFM_GETDEFSTATICID
Definition: precomp.h:47
LONG HRESULT
Definition: typedefs.h:79
UINT idCmdFirst
Definition: shlobj.h:1317
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
#define DFM_MERGECONTEXTMENU
Definition: precomp.h:44
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2429
UINT cidl
Definition: shlobj.h:499
const char * DFM_TO_STR(UINT uMsg)
Definition: CFontMenu.cpp:45
#define ERR(fmt,...)
Definition: debug.h:110
#define MIIM_STRING
Definition: winuser.h:722
#define S_OK
Definition: intsafe.h:52
static void RunFontViewer(HWND hwnd, const FontPidlEntry *fontEntry)
Definition: CFontMenu.cpp:67
#define IDS_FONT_PREVIEW
Definition: resource.h:13
#define E_NOTIMPL
Definition: ddrawi.h:99
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
unsigned int UINT
Definition: ndis.h:50
#define DFM_INVOKECOMMANDEX
Definition: precomp.h:46
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LPARAM lParam
Definition: combotst.c:139

Referenced by _CFontMenu_CreateInstance().

◆ RunFontViewer()

static void RunFontViewer ( HWND  hwnd,
const FontPidlEntry fontEntry 
)
static

Definition at line 67 of file CFontMenu.cpp.

68 {
69  WCHAR FontViewerPath[MAX_PATH] = L"%SystemRoot%\\System32\\fontview.exe";
70  WCHAR FontPathArg[MAX_PATH + 3];
71 
72  CStringW Path = g_FontCache->Filename(g_FontCache->Find(fontEntry), true);
73  if (!Path.IsEmpty())
74  {
75  // '/d' disables the install button
76  StringCchPrintfW(FontPathArg, _countof(FontPathArg), L"/d %s", Path.GetString());
77  PathQuoteSpacesW(FontPathArg + 3);
78 
79  SHELLEXECUTEINFOW si = { sizeof(si) };
81  si.hwnd = hwnd;
82  si.lpFile = FontViewerPath;
83  si.lpParameters = FontPathArg;
84  si.nShow = SW_SHOWNORMAL;
85  ShellExecuteExW(&si);
86  }
87 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2263
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
#define SEE_MASK_DOENVSUBST
Definition: shellapi.h:35
static const WCHAR L[]
Definition: oid.c:1250
CFontCache * g_FontCache
Definition: CFontCache.cpp:12
#define SW_SHOWNORMAL
Definition: winuser.h:764
PRTL_UNICODE_STRING_BUFFER Path
LPCWSTR lpParameters
Definition: shellapi.h:331
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
CFontInfo * Find(const FontPidlEntry *fontEntry)
Definition: CFontCache.cpp:145
CStringW Filename(CFontInfo *info, bool alwaysFullPath=false)
Definition: CFontCache.cpp:164
VOID WINAPI PathQuoteSpacesW(LPWSTR lpszPath)
Definition: path.c:978

Referenced by FontFolderMenuCallback().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( fontext  )

Variable Documentation

◆ g_cfHIDA

CLIPFORMAT g_cfHIDA
static

Definition at line 12 of file CFontMenu.cpp.

Referenced by _GetCidlFromDataObject().