4 * Copyright 2008 Johannes Anderwald <johannes.anderwald@reactos.org>
5 * Copyright 2009 Andrew Hill
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 WINE_DEFAULT_DEBUG_CHANNEL (shell
);
27 This folder should not exist. It is just a file system folder... The \windows\fonts
28 directory contains a hidden desktop.ini with a UIHandler entry that specifies a class
29 that lives in fontext.dll. The UI handler creates a custom view for the folder, which
30 is what we normally see. However, the folder is a perfectly normal CFSFolder.
33 /***********************************************************************
34 * IShellFolder implementation
37 class CDesktopFolderEnumZ
: public IEnumIDListImpl
40 CDesktopFolderEnumZ();
41 ~CDesktopFolderEnumZ();
42 HRESULT WINAPI
Initialize(DWORD dwFlags
);
43 BOOL
CreateFontsEnumList(DWORD dwFlags
);
45 BEGIN_COM_MAP(CDesktopFolderEnumZ
)
46 COM_INTERFACE_ENTRY_IID(IID_IEnumIDList
, IEnumIDList
)
50 static shvheader FontsSFHeader
[] = {
51 {IDS_SHV_COLUMN8
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},
52 {IDS_SHV_COLUMN_FONTTYPE
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},
53 {IDS_SHV_COLUMN2
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},
54 {IDS_SHV_COLUMN12
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15}
60 #define COLUMN_FILENAME 3
62 #define FontsSHELLVIEWCOLUMNS (4)
64 CDesktopFolderEnumZ::CDesktopFolderEnumZ()
68 CDesktopFolderEnumZ::~CDesktopFolderEnumZ()
72 HRESULT WINAPI
CDesktopFolderEnumZ::Initialize(DWORD dwFlags
)
74 if (CreateFontsEnumList(dwFlags
) == FALSE
)
79 static LPITEMIDLIST
_ILCreateFontItem(LPWSTR pszFont
, LPWSTR pszFile
)
83 int length
= wcslen(pszFont
) + 1;
84 int size
= sizeof(PIDLDATA
) + sizeof(ITEMIDLIST
);
86 size
+= length
* sizeof(WCHAR
);
87 size
+= (wcslen(pszFile
) + 1) * sizeof(WCHAR
);
89 pidl
= (LPITEMIDLIST
)SHAlloc(size
+ 5);
93 ZeroMemory(pidl
, size
+ 5);
94 pidl
->mkid
.cb
= size
+ 3;
96 data
= _ILGetDataPointer(pidl
);
98 data
->u
.cfont
.dummy
= 0xFF;
99 data
->u
.cfont
.offsFile
= length
;
100 wcscpy(data
->u
.cfont
.szName
, pszFont
);
101 wcscpy(&data
->u
.cfont
.szName
[length
], pszFile
);
106 static PIDLFontStruct
* _ILGetFontStruct(LPCITEMIDLIST pidl
)
108 LPPIDLDATA pdata
= _ILGetDataPointer(pidl
);
110 if (pdata
&& pdata
->type
== 0x00)
111 return (PIDLFontStruct
*) & (pdata
->u
.cfont
);
116 /**************************************************************************
117 * CDesktopFolderEnumZ::CreateFontsEnumList()
119 BOOL
CDesktopFolderEnumZ::CreateFontsEnumList(DWORD dwFlags
)
121 WCHAR szPath
[MAX_PATH
];
122 WCHAR szName
[LF_FACESIZE
+20];
123 WCHAR szFile
[MAX_PATH
];
127 DWORD dwType
, dwName
, dwFile
, dwIndex
;
131 if (dwFlags
& SHCONTF_NONFOLDERS
)
133 if (!SHGetSpecialFolderPathW(NULL
, szPath
, CSIDL_FONTS
, FALSE
))
136 pszPath
= PathAddBackslashW(szPath
);
139 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts", 0, KEY_READ
, &hKey
) != ERROR_SUCCESS
)
142 Length
= pszPath
- szPath
;
146 dwName
= sizeof(szName
) / sizeof(WCHAR
);
147 dwFile
= sizeof(szFile
) / sizeof(WCHAR
);
148 ret
= RegEnumValueW(hKey
, dwIndex
++, szName
, &dwName
, NULL
, &dwType
, (LPBYTE
)szFile
, &dwFile
);
149 if (ret
== ERROR_SUCCESS
)
151 szFile
[(sizeof(szFile
)/sizeof(WCHAR
))-1] = L
'\0';
152 if (dwType
== REG_SZ
&& wcslen(szFile
) + Length
+ 1 < (sizeof(szPath
) / sizeof(WCHAR
)))
154 wcscpy(&szPath
[Length
], szFile
);
155 pidl
= _ILCreateFontItem(szName
, szPath
);
156 TRACE("pidl %p name %s path %s\n", pidl
, debugstr_w(szName
), debugstr_w(szPath
));
159 if (!AddToEnumList(pidl
))
164 } while(ret
!= ERROR_NO_MORE_ITEMS
);
171 CFontsFolder::CFontsFolder()
177 CFontsFolder::~CFontsFolder()
179 TRACE("-- destroying IShellFolder(%p)\n", this);
183 HRESULT WINAPI
CFontsFolder::FinalConstruct()
185 pidlRoot
= _ILCreateFont(); /* my qualified pidl */
186 if (pidlRoot
== NULL
)
187 return E_OUTOFMEMORY
;
191 /**************************************************************************
192 * CFontsFolder::ParseDisplayName
194 HRESULT WINAPI
CFontsFolder::ParseDisplayName(
197 LPOLESTR lpszDisplayName
,
199 PIDLIST_RELATIVE
*ppidl
,
200 DWORD
* pdwAttributes
)
202 HRESULT hr
= E_UNEXPECTED
;
204 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", this,
205 hwndOwner
, pbcReserved
, lpszDisplayName
, debugstr_w (lpszDisplayName
),
206 pchEaten
, ppidl
, pdwAttributes
);
210 *pchEaten
= 0; /* strange but like the original */
212 TRACE ("(%p)->(-- ret=0x%08x)\n", this, hr
);
217 /**************************************************************************
218 * CFontsFolder::EnumObjects
220 HRESULT WINAPI
CFontsFolder::EnumObjects(HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
*ppEnumIDList
)
222 CComObject
<CDesktopFolderEnumZ
> *theEnumerator
;
223 CComPtr
<IEnumIDList
> result
;
226 TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", this, hwndOwner
, dwFlags
, ppEnumIDList
);
228 if (ppEnumIDList
== NULL
)
230 *ppEnumIDList
= NULL
;
231 ATLTRY (theEnumerator
= new CComObject
<CDesktopFolderEnumZ
>);
232 if (theEnumerator
== NULL
)
233 return E_OUTOFMEMORY
;
234 hResult
= theEnumerator
->QueryInterface(IID_PPV_ARG(IEnumIDList
, &result
));
235 if (FAILED (hResult
))
237 delete theEnumerator
;
240 hResult
= theEnumerator
->Initialize (dwFlags
);
241 if (FAILED (hResult
))
243 *ppEnumIDList
= result
.Detach ();
245 TRACE ("-- (%p)->(new ID List: %p)\n", this, *ppEnumIDList
);
250 /**************************************************************************
251 * CFontsFolder::BindToObject
253 HRESULT WINAPI
CFontsFolder::BindToObject(PCUIDLIST_RELATIVE pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
*ppvOut
)
255 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", this,
256 pidl
, pbcReserved
, shdebugstr_guid (&riid
), ppvOut
);
258 return SHELL32_BindToChild (pidlRoot
, NULL
, pidl
, riid
, ppvOut
);
261 /**************************************************************************
262 * CFontsFolder::BindToStorage
264 HRESULT WINAPI
CFontsFolder::BindToStorage(PCUIDLIST_RELATIVE pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
*ppvOut
)
266 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", this,
267 pidl
, pbcReserved
, shdebugstr_guid (&riid
), ppvOut
);
273 /**************************************************************************
274 * CFontsFolder::CompareIDs
277 HRESULT WINAPI
CFontsFolder::CompareIDs(LPARAM lParam
, PCUIDLIST_RELATIVE pidl1
, PCUIDLIST_RELATIVE pidl2
)
281 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", this, lParam
, pidl1
, pidl2
);
282 nReturn
= SHELL32_CompareIDs (this, lParam
, pidl1
, pidl2
);
283 TRACE ("-- %i\n", nReturn
);
287 /**************************************************************************
288 * CFontsFolder::CreateViewObject
290 HRESULT WINAPI
CFontsFolder::CreateViewObject(HWND hwndOwner
, REFIID riid
, LPVOID
*ppvOut
)
292 CComPtr
<IShellView
> pShellView
;
293 HRESULT hr
= E_INVALIDARG
;
295 TRACE ("(%p)->(hwnd=%p,%s,%p)\n", this,
296 hwndOwner
, shdebugstr_guid (&riid
), ppvOut
);
303 if (IsEqualIID (riid
, IID_IDropTarget
))
305 WARN ("IDropTarget not implemented\n");
308 else if (IsEqualIID (riid
, IID_IContextMenu
))
310 WARN ("IContextMenu not implemented\n");
313 else if (IsEqualIID (riid
, IID_IShellView
))
315 hr
= IShellView_Constructor (this, &pShellView
);
317 hr
= pShellView
->QueryInterface(riid
, ppvOut
);
319 TRACE ("-- (%p)->(interface=%p)\n", this, ppvOut
);
323 /**************************************************************************
324 * CFontsFolder::GetAttributesOf
326 HRESULT WINAPI
CFontsFolder::GetAttributesOf(UINT cidl
, PCUITEMID_CHILD_ARRAY apidl
, DWORD
*rgfInOut
)
330 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n", this,
331 cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
343 CComPtr
<IShellFolder
> psfParent
;
344 LPCITEMIDLIST rpidl
= NULL
;
346 hr
= SHBindToParent(pidlRoot
, IID_PPV_ARG(IShellFolder
, &psfParent
), (LPCITEMIDLIST
*)&rpidl
);
348 SHELL32_GetItemAttributes (psfParent
, rpidl
, rgfInOut
);
352 while (cidl
> 0 && *apidl
)
355 SHELL32_GetItemAttributes (this, *apidl
, rgfInOut
);
361 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
362 *rgfInOut
&= ~SFGAO_VALIDATE
;
364 TRACE ("-- result=0x%08x\n", *rgfInOut
);
368 /**************************************************************************
369 * CFontsFolder::GetUIObjectOf
372 * hwndOwner [in] Parent window for any output
373 * cidl [in] array size
374 * apidl [in] simple pidl array
375 * riid [in] Requested Interface
376 * prgfInOut [ ] reserved
377 * ppvObject [out] Resulting Interface
380 HRESULT WINAPI
CFontsFolder::GetUIObjectOf(
382 UINT cidl
, PCUITEMID_CHILD_ARRAY apidl
,
383 REFIID riid
, UINT
*prgfInOut
, LPVOID
*ppvOut
)
386 CComPtr
<IUnknown
> pObj
;
387 HRESULT hr
= E_INVALIDARG
;
389 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", this,
390 hwndOwner
, cidl
, apidl
, shdebugstr_guid (&riid
), prgfInOut
, ppvOut
);
397 if (IsEqualIID (riid
, IID_IContextMenu
) && (cidl
>= 1))
399 pObj
= (IContextMenu
*)this;
400 this->apidl
= apidl
[0];
403 else if (IsEqualIID (riid
, IID_IDataObject
) && (cidl
>= 1))
405 hr
= IDataObject_Constructor (hwndOwner
, pidlRoot
, apidl
, cidl
, (IDataObject
**)&pObj
);
407 else if (IsEqualIID (riid
, IID_IExtractIconA
) && (cidl
== 1))
409 pidl
= ILCombine (pidlRoot
, apidl
[0]);
410 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor (pidl
);
414 else if (IsEqualIID (riid
, IID_IExtractIconW
) && (cidl
== 1))
416 pidl
= ILCombine (pidlRoot
, apidl
[0]);
417 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor (pidl
);
421 else if (IsEqualIID (riid
, IID_IDropTarget
) && (cidl
>= 1))
423 hr
= this->QueryInterface(IID_IDropTarget
, (LPVOID
*) & pObj
);
428 if (SUCCEEDED(hr
) && !pObj
)
431 *ppvOut
= pObj
.Detach();
432 TRACE ("(%p)->hr=0x%08x\n", this, hr
);
436 /**************************************************************************
437 * CFontsFolder::GetDisplayNameOf
440 HRESULT WINAPI
CFontsFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl
, DWORD dwFlags
, LPSTRRET strRet
)
442 PIDLFontStruct
*pFont
;
444 TRACE("(%p)->(pidl=%p,0x%08x,%p)\n", this, pidl
, dwFlags
, strRet
);
450 pFont
= _ILGetFontStruct(pidl
);
453 strRet
->pOleStr
= (LPWSTR
)CoTaskMemAlloc((wcslen(pFont
->szName
) + 1) * sizeof(WCHAR
));
454 if (!strRet
->pOleStr
)
455 return E_OUTOFMEMORY
;
457 wcscpy(strRet
->pOleStr
, pFont
->szName
);
458 strRet
->uType
= STRRET_WSTR
;
460 else if (!pidl
->mkid
.cb
)
462 WCHAR wszPath
[MAX_PATH
];
464 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
465 (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
))
467 if (!SHGetSpecialFolderPathW(NULL
, wszPath
, CSIDL_FONTS
, FALSE
))
470 else if (!HCR_GetClassNameW(CLSID_FontsFolderShortcut
, wszPath
, MAX_PATH
))
473 strRet
->pOleStr
= (LPWSTR
)CoTaskMemAlloc((wcslen(wszPath
) + 1) * sizeof(WCHAR
));
474 if (!strRet
->pOleStr
)
475 return E_OUTOFMEMORY
;
477 wcscpy(strRet
->pOleStr
, wszPath
);
478 strRet
->uType
= STRRET_WSTR
;
486 /**************************************************************************
487 * CFontsFolder::SetNameOf
488 * Changes the name of a file object or subfolder, possibly changing its item
489 * identifier in the process.
492 * hwndOwner [in] Owner window for output
493 * pidl [in] simple pidl of item to change
494 * lpszName [in] the items new display name
495 * dwFlags [in] SHGNO formatting flags
496 * ppidlOut [out] simple pidl returned
498 HRESULT WINAPI
CFontsFolder::SetNameOf(HWND hwndOwner
, PCUITEMID_CHILD pidl
, /*simple pidl */
499 LPCOLESTR lpName
, DWORD dwFlags
, PITEMID_CHILD
*pPidlOut
)
501 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", this,
502 hwndOwner
, pidl
, debugstr_w (lpName
), dwFlags
, pPidlOut
);
506 HRESULT WINAPI
CFontsFolder::GetDefaultSearchGUID(GUID
*pguid
)
508 FIXME ("(%p)\n", this);
512 HRESULT WINAPI
CFontsFolder::EnumSearches(IEnumExtraSearch
**ppenum
)
514 FIXME ("(%p)\n", this);
518 HRESULT WINAPI
CFontsFolder::GetDefaultColumn(DWORD dwRes
, ULONG
*pSort
, ULONG
*pDisplay
)
520 TRACE ("(%p)\n", this);
530 HRESULT WINAPI
CFontsFolder::GetDefaultColumnState(UINT iColumn
, DWORD
*pcsFlags
)
532 TRACE ("(%p)\n", this);
534 if (!pcsFlags
|| iColumn
>= FontsSHELLVIEWCOLUMNS
)
536 *pcsFlags
= FontsSFHeader
[iColumn
].pcsFlags
;
540 HRESULT WINAPI
CFontsFolder::GetDetailsEx(PCUITEMID_CHILD pidl
, const SHCOLUMNID
*pscid
, VARIANT
*pv
)
542 FIXME ("(%p)\n", this);
546 HRESULT WINAPI
CFontsFolder::GetDetailsOf(PCUITEMID_CHILD pidl
, UINT iColumn
, SHELLDETAILS
*psd
)
548 WCHAR buffer
[MAX_PATH
] = {0};
550 PIDLFontStruct
* pfont
;
552 LARGE_INTEGER FileSize
;
555 TRACE("(%p, %p, %d, %p)\n", this, pidl
, iColumn
, psd
);
557 if (iColumn
>= FontsSHELLVIEWCOLUMNS
)
560 psd
->fmt
= FontsSFHeader
[iColumn
].fmt
;
561 psd
->cxChar
= FontsSFHeader
[iColumn
].cxChar
;
564 psd
->str
.uType
= STRRET_WSTR
;
565 if (LoadStringW(shell32_hInstance
, FontsSFHeader
[iColumn
].colnameid
, buffer
, MAX_PATH
))
566 hr
= SHStrDupW(buffer
, &psd
->str
.pOleStr
);
571 if (iColumn
== COLUMN_NAME
)
573 psd
->str
.uType
= STRRET_WSTR
;
574 return GetDisplayNameOf(pidl
, SHGDN_NORMAL
, &psd
->str
);
577 psd
->str
.uType
= STRRET_CSTR
;
578 psd
->str
.cStr
[0] = '\0';
583 pfont
= _ILGetFontStruct(pidl
);
586 if (SHGetFileInfoW(pfont
->szName
+ pfont
->offsFile
, 0, &fi
, sizeof(fi
), SHGFI_TYPENAME
))
588 psd
->str
.pOleStr
= (LPWSTR
)CoTaskMemAlloc((wcslen(fi
.szTypeName
) + 1) * sizeof(WCHAR
));
589 if (!psd
->str
.pOleStr
)
590 return E_OUTOFMEMORY
;
591 wcscpy(psd
->str
.pOleStr
, fi
.szTypeName
);
592 psd
->str
.uType
= STRRET_WSTR
;
598 pfont
= _ILGetFontStruct(pidl
);
601 hFile
= CreateFileW(pfont
->szName
+ pfont
->offsFile
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
602 if (hFile
!= INVALID_HANDLE_VALUE
)
604 if (GetFileSizeEx(hFile
, &FileSize
))
606 if (StrFormatByteSizeW(FileSize
.QuadPart
, buffer
, sizeof(buffer
) / sizeof(WCHAR
)))
608 psd
->str
.pOleStr
= (LPWSTR
)CoTaskMemAlloc((wcslen(buffer
) + 1) * sizeof(WCHAR
));
609 if (!psd
->str
.pOleStr
)
612 return E_OUTOFMEMORY
;
614 wcscpy(psd
->str
.pOleStr
, buffer
);
615 psd
->str
.uType
= STRRET_WSTR
;
624 case COLUMN_FILENAME
:
625 pfont
= _ILGetFontStruct(pidl
);
628 psd
->str
.pOleStr
= (LPWSTR
)CoTaskMemAlloc((wcslen(pfont
->szName
+ pfont
->offsFile
) + 1) * sizeof(WCHAR
));
629 if (psd
->str
.pOleStr
)
631 psd
->str
.uType
= STRRET_WSTR
;
632 wcscpy(psd
->str
.pOleStr
, pfont
->szName
+ pfont
->offsFile
);
636 return E_OUTOFMEMORY
;
644 HRESULT WINAPI
CFontsFolder::MapColumnToSCID(UINT column
, SHCOLUMNID
*pscid
)
646 FIXME ("(%p)\n", this);
651 /************************************************************************
652 * CFontsFolder::GetClassID
654 HRESULT WINAPI
CFontsFolder::GetClassID(CLSID
*lpClassId
)
656 TRACE ("(%p)\n", this);
661 *lpClassId
= CLSID_FontsFolderShortcut
;
666 /************************************************************************
667 * CFontsFolder::Initialize
669 * NOTES: it makes no sense to change the pidl
671 HRESULT WINAPI
CFontsFolder::Initialize(LPCITEMIDLIST pidl
)
673 TRACE ("(%p)->(%p)\n", this, pidl
);
678 /**************************************************************************
679 * CFontsFolder::GetCurFolder
681 HRESULT WINAPI
CFontsFolder::GetCurFolder(LPITEMIDLIST
*pidl
)
683 TRACE ("(%p)->(%p)\n", this, pidl
);
688 *pidl
= ILClone(pidlRoot
);
693 /**************************************************************************
694 * IContextMenu2 Implementation
697 /**************************************************************************
698 * CFontsFolder::QueryContextMenu()
700 HRESULT WINAPI
CFontsFolder::QueryContextMenu(HMENU hMenu
, UINT indexMenu
, UINT idCmdFirst
, UINT idCmdLast
, UINT uFlags
)
702 WCHAR szBuffer
[30] = {0};
705 TRACE("(%p)->(hmenu=%p indexmenu=%x cmdfirst=%x cmdlast=%x flags=%x )\n",
706 this, hMenu
, indexMenu
, idCmdFirst
, idCmdLast
, uFlags
);
708 if (LoadStringW(shell32_hInstance
, IDS_OPEN
, szBuffer
, sizeof(szBuffer
) / sizeof(WCHAR
)))
710 szBuffer
[(sizeof(szBuffer
)/sizeof(WCHAR
))-1] = L
'\0';
711 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, idCmdFirst
+ Count
, MFT_STRING
, szBuffer
, MFS_DEFAULT
);
715 if (LoadStringW(shell32_hInstance
, IDS_PRINT_VERB
, szBuffer
, sizeof(szBuffer
) / sizeof(WCHAR
)))
717 szBuffer
[(sizeof(szBuffer
)/sizeof(WCHAR
))-1] = L
'\0';
718 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, idCmdFirst
+ Count
++, MFT_STRING
, szBuffer
, MFS_ENABLED
);
721 if (LoadStringW(shell32_hInstance
, IDS_COPY
, szBuffer
, sizeof(szBuffer
) / sizeof(WCHAR
)))
723 szBuffer
[(sizeof(szBuffer
)/sizeof(WCHAR
))-1] = L
'\0';
724 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, idCmdFirst
+ Count
++, MFT_SEPARATOR
, NULL
, MFS_ENABLED
);
725 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, idCmdFirst
+ Count
++, MFT_STRING
, szBuffer
, MFS_ENABLED
);
728 if (LoadStringW(shell32_hInstance
, IDS_DELETE
, szBuffer
, sizeof(szBuffer
) / sizeof(WCHAR
)))
730 szBuffer
[(sizeof(szBuffer
)/sizeof(WCHAR
))-1] = L
'\0';
731 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, idCmdFirst
+ Count
++, MFT_SEPARATOR
, NULL
, MFS_ENABLED
);
732 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, idCmdFirst
+ Count
, MFT_STRING
, szBuffer
, MFS_ENABLED
);
735 if (LoadStringW(shell32_hInstance
, IDS_PROPERTIES
, szBuffer
, sizeof(szBuffer
) / sizeof(WCHAR
)))
737 szBuffer
[(sizeof(szBuffer
)/sizeof(WCHAR
))-1] = L
'\0';
738 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, idCmdFirst
+ Count
++, MFT_SEPARATOR
, NULL
, MFS_ENABLED
);
739 _InsertMenuItemW(hMenu
, indexMenu
++, TRUE
, idCmdFirst
+ Count
, MFT_STRING
, szBuffer
, MFS_ENABLED
);
742 return MAKE_HRESULT(SEVERITY_SUCCESS
, 0, Count
);
745 /**************************************************************************
746 * CFontsFolder::InvokeCommand()
748 HRESULT WINAPI
CFontsFolder::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi
)
750 SHELLEXECUTEINFOW sei
;
751 PIDLFontStruct
* pfont
;
754 TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n", this, lpcmi
, lpcmi
->lpVerb
, lpcmi
->hwnd
);
756 if (lpcmi
->lpVerb
== MAKEINTRESOURCEA(1) || lpcmi
->lpVerb
== MAKEINTRESOURCEA(2) || lpcmi
->lpVerb
== MAKEINTRESOURCEA(7))
758 ZeroMemory(&sei
, sizeof(sei
));
759 sei
.cbSize
= sizeof(sei
);
760 sei
.hwnd
= lpcmi
->hwnd
;
761 sei
.nShow
= SW_SHOWNORMAL
;
762 if (lpcmi
->lpVerb
== MAKEINTRESOURCEA(1))
763 sei
.lpVerb
= L
"open";
764 else if (lpcmi
->lpVerb
== MAKEINTRESOURCEA(2))
765 sei
.lpVerb
= L
"print";
766 else if (lpcmi
->lpVerb
== MAKEINTRESOURCEA(7))
767 sei
.lpVerb
= L
"properties";
769 pfont
= _ILGetFontStruct(apidl
);
770 sei
.lpFile
= pfont
->szName
+ pfont
->offsFile
;
772 if (ShellExecuteExW(&sei
) == FALSE
)
775 else if (lpcmi
->lpVerb
== MAKEINTRESOURCEA(4))
777 FIXME("implement font copying\n");
780 else if (lpcmi
->lpVerb
== MAKEINTRESOURCEA(6))
782 ZeroMemory(&op
, sizeof(op
));
783 op
.hwnd
= lpcmi
->hwnd
;
784 op
.wFunc
= FO_DELETE
;
785 op
.fFlags
= FOF_ALLOWUNDO
;
786 pfont
= _ILGetFontStruct(apidl
);
787 op
.pFrom
= pfont
->szName
+ pfont
->offsFile
;
788 SHFileOperationW(&op
);
794 /**************************************************************************
795 * CFontsFolder::GetCommandString()
798 HRESULT WINAPI
CFontsFolder::GetCommandString(UINT_PTR idCommand
, UINT uFlags
, UINT
*lpReserved
, LPSTR lpszName
, UINT uMaxNameLen
)
800 TRACE("(%p)->(idcom=%lx flags=%x %p name=%p len=%x)\n", this, idCommand
, uFlags
, lpReserved
, lpszName
, uMaxNameLen
);
805 /**************************************************************************
806 * CFontsFolder::HandleMenuMsg()
808 HRESULT WINAPI
CFontsFolder::HandleMenuMsg(UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
810 TRACE("(%p)->(msg=%x wp=%lx lp=%lx)\n", this, uMsg
, wParam
, lParam
);