本文整理汇总了C++中CComObject::AddPages方法的典型用法代码示例。如果您正苦于以下问题:C++ CComObject::AddPages方法的具体用法?C++ CComObject::AddPages怎么用?C++ CComObject::AddPages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComObject
的用法示例。
在下文中一共展示了CComObject::AddPages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SH_ShowDriveProperties
BOOL
SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, LPCITEMIDLIST *apidl)
{
HPSXA hpsxa[3] = {NULL, NULL, NULL};
CComObject<CFileDefExt> *pFileDefExt = NULL;
TRACE("SH_ShowPropertiesDialog entered filename %s\n", debugstr_w(pwszPath));
if (pwszPath == NULL || !wcslen(pwszPath))
return FALSE;
HPROPSHEETPAGE hppages[MAX_PROPERTY_SHEET_PAGE];
memset(hppages, 0x0, sizeof(HPROPSHEETPAGE) * MAX_PROPERTY_SHEET_PAGE);
/* Make a copy of path */
WCHAR wszPath[MAX_PATH];
StringCbCopyW(wszPath, sizeof(wszPath), pwszPath);
/* remove trailing \\ at the end of path */
PathRemoveBackslashW(wszPath);
/* Handle drives */
if (PathIsRootW(wszPath))
return SH_ShowDriveProperties(wszPath, pidlFolder, apidl);
/* Handle files and folders */
PROPSHEETHEADERW Header;
memset(&Header, 0x0, sizeof(PROPSHEETHEADERW));
Header.dwSize = sizeof(PROPSHEETHEADERW);
Header.dwFlags = PSH_NOCONTEXTHELP | PSH_PROPTITLE;
Header.phpage = hppages;
Header.pszCaption = PathFindFileNameW(wszPath);
CComPtr<IDataObject> pDataObj;
HRESULT hr = SHCreateDataObject(pidlFolder, 1, apidl, NULL, IID_IDataObject, (LPVOID *)&pDataObj);
if (SUCCEEDED(hr))
{
hr = CComObject<CFileDefExt>::CreateInstance(&pFileDefExt);
if (SUCCEEDED(hr))
{
pFileDefExt->AddRef(); // CreateInstance returns object with 0 ref count
hr = pFileDefExt->Initialize(pidlFolder, pDataObj, NULL);
if (SUCCEEDED(hr))
{
hr = pFileDefExt->AddPages(AddPropSheetPageCallback, (LPARAM)&Header);
if (FAILED(hr))
ERR("AddPages failed\n");
} else
ERR("Initialize failed\n");
}
LoadPropSheetHandlers(wszPath, &Header, MAX_PROPERTY_SHEET_PAGE - 1, hpsxa, pDataObj);
}
INT_PTR Result = PropertySheetW(&Header);
for (UINT i = 0; i < 3; ++i)
if (hpsxa[i])
SHDestroyPropSheetExtArray(hpsxa[i]);
if (pFileDefExt)
pFileDefExt->Release();
return (Result != -1);
}