当前位置: 首页>>代码示例>>C++>>正文


C++ CComObject::Deserialize方法代码示例

本文整理汇总了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;
}
开发者ID:,项目名称:,代码行数:84,代码来源:


注:本文中的CComObject::Deserialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。