本文整理汇总了C++中CComObject::Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C++ CComObject::Deserialize方法的具体用法?C++ CComObject::Deserialize怎么用?C++ CComObject::Deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComObject
的用法示例。
在下文中一共展示了CComObject::Deserialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnFileOpen
LRESULT CPageDesignerApp::OnFileOpen(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
static LPCTSTR FilesFilter = _T( "All Files\0*.*\0"
"PageDesigner Document (*.pddoc)\0*.pddoc\0"
);
TCHAR sbuffer[4096];
strcpy(sbuffer, ""); // Initial filename
TCHAR curdir[MAX_PATH];
GetCurrentDirectory(sizeof(curdir), curdir);
HWND hwnd = GetMainHwnd();
OPENFILENAME ofn = {0};
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;//sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.hInstance = _Module.m_hInst;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrFile = sbuffer;
ofn.nMaxFile = sizeof(sbuffer);
ofn.lpstrInitialDir = curdir;
ofn.lpstrFilter = FilesFilter;
if (GetOpenFileName(&ofn))
{
BOOL success = FALSE;
CComPtr<IArchive> ar;
ar.CoCreateInstance(CLSID_Archive);
CComPtr<IArchiveElement> node;
if (SUCCEEDED(ar->Open(_bstr_t(sbuffer), 2, L"pddoc", &node)))
{
CComObject<CPDDocument>* pddocument;
CComObject<CPDDocument>::CreateInstance(&pddocument);
if (pddocument)
{
pddocument->AddRef();
HRESULT hr = pddocument->Deserialize(ar, node, NULL);
success = SUCCEEDED(hr);
pddocument->ShowViews();
}
}
/*
LPTSTR ext = PathFindExtension(sbuffer);
CComPtr<IDOMDocument> document;
document.CoCreateInstance(CLSID_LDOMDocument);
VARIANT_BOOL bloaded;
document->load(_bstr_t(sbuffer), &bloaded);
if (bloaded)
{
CComPtr<IDOMElement> documentElement;
document->get_documentElement(&documentElement);
if (documentElement)
{
CComObject<CPDDocument>* pddocument;
CComObject<CPDDocument>::CreateInstance(&pddocument);
if (pddocument)
{
pddocument->AddRef();
HRESULT hr = pddocument->loadXML(documentElement);
success = SUCCEEDED(hr);
pddocument->ShowViews();
}
}
}
*/
if (!success)
{
MessageBox(GetMainHwnd(), "Failed to load document", "PageDesigner", MB_OK);
}
}
return 0;
}