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


C++ IDocument::Close方法代码示例

本文整理汇总了C++中IDocument::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ IDocument::Close方法的具体用法?C++ IDocument::Close怎么用?C++ IDocument::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDocument的用法示例。


在下文中一共展示了IDocument::Close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ocr


//.........这里部分代码省略.........
	strDebug.Format("OCR %s!", pszName);
	MessageBox(NULL, strDebug, "OCR.DLL", MB_ICONINFORMATION);
#endif

	hr = CoInitialize(0);
	// hr = CoInitializeEx(pReserved, COINIT_MULTITHREADED);
	// hr = CoInitializeEx(pReserved, COINIT_APARTMENTTHREADED);
#if _OCR_DEBUG > 0
	strDebug.Format("CoInitialize result = 0x%08X!", hr);
	MessageBox(NULL, strDebug, "OCR.DLL", MB_ICONINFORMATION);
#endif
	if (!SUCCEEDED(hr)) return;

	hr = CoCreateInstance(CLSID_Document, NULL, CLSCTX_INPROC_SERVER, IID_IDocument, (void**) &pDoc);
	// hr = CoCreateInstance(CLSID_Document, NULL, CLSCTX_INPROC_SERVER, IID_IDocument, (void**) &pDisp);
	// hr = pDisp->QueryInterface(IID_IDocument, (void**) &pDoc);
	// hr = pDoc.CoCreateInstance(CLSID_Document);
	// hr = CoGetClassObject(CLSID_Document, CLSCTX_INPROC_SERVER, NULL, IID_IDocument, (void**) &pDoc);
#if _OCR_DEBUG > 0
	strDebug.Format("CoCreateInstance result = 0x%08X!", hr);
	MessageBox(NULL, strDebug, "OCR.DLL", MB_ICONINFORMATION);
#endif
	if (!SUCCEEDED(hr)) return;

	bstrName = pszName;
	hr = pDoc->Create(bstrName);
#if _OCR_DEBUG > 0
	strDebug.Format("IDocument created, result = 0x%08X!", hr);
	MessageBox(NULL, strDebug, "OCR.DLL", MB_ICONINFORMATION);
#endif
	if (!SUCCEEDED(hr)) return;

	hr = pDoc->OCR(miLANG_CHINESE_SIMPLIFIED, FALSE, FALSE);
#if _OCR_DEBUG > 0
	strDebug.Format("IDocument OCR result = 0x%08X!", hr);
	MessageBox(NULL, strDebug, "OCR.DLL", MB_ICONINFORMATION);
#endif
	if (!SUCCEEDED(hr)) return;

	pDoc->get_Images(&pImages);
	pImages->get_Count(&iCount);
  for (long i = 0; i < iCount; i++ )
  {
		pImages->get_Item(i, (IDispatch**)&pImage);
    pImage->get_Layout(&pLayout);
		pLayout->get_Words(&pWords);
		pWords->get_Count(&wCount);

		for (long j = 0; j < wCount; j++)
		{
			pWords->get_Item(j, (IDispatch**)&pWord);
			pWord->get_Rects(&pRects);
			pRects->get_Count(&rCount);
			minTop = maxBottom = 0;
			for (long k = 0; k < rCount; k++)
			{
				pRects->get_Item(k, (IDispatch**)&pRect);
				pRect->get_Left(&left);
				pRect->get_Top(&top);
				pRect->get_Right(&right);
				pRect->get_Bottom(&bottom);
				if (minTop == 0) minTop = top;
				if (minTop > top) minTop = top;
				if (maxBottom < bottom) maxBottom = bottom;
				if (pRect) pRect->Release();
			}
			if (pRects) pRects->Release();
			if (savedMaxBottom == 0) savedMaxBottom = maxBottom;
			if (minTop >= savedMaxBottom)
			{
				tConf /= count;
				savedMaxBottom = maxBottom;
				strText = "";
				tConf = 0.0;
				count = 0;
			}
			pWord->get_Text(&bstrText);
			pWord->get_RecognitionConfidence(&conf);
			tConf += conf;
			count++;
			strText += bstrText ? OLE2CT(bstrText) : _T("");
			if (pWord) pWord->Release();
		}
		if (strText.GetLength() > 0)
		{
				tConf /= count;
				strText = "";
				tConf = 0.0;
				count = 0;
		}
		if (pWords) pWords->Release();
		if (pLayout) pLayout->Release();
		if (pImage) pImage->Release();
  }
	if (pImages) pImages->Release();
  pDoc->Close(0);
  pDoc->Release();
	CoUninitialize();
	return pItems;
}
开发者ID:harrysun2006,项目名称:07_Sylla,代码行数:101,代码来源:ocr2.cpp


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