LRESULT IGToolCutterSquare::OnMouseUp (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	CComSafeArray <int> spSafeArrayPts;
	spSafeArrayPts.Add (m_xPos1);
	spSafeArrayPts.Add (m_yPos1);
	m_xPos1 = GET_X_LPARAM(lParam); 
	m_yPos1 = GET_Y_LPARAM(lParam); 
	m_pFrame->ConvertCoordFrameToPixel ((LONG*)&m_xPos1, (LONG*)&m_yPos1);
	spSafeArrayPts.Add (m_xPos1);
	spSafeArrayPts.Add (m_yPos1);
	CComVariant spVarArray (spSafeArrayPts);
	int nTypeSelection = IGSELECTION_REPLACE;
	if (::GetKeyState (VK_SHIFT) < 0)
		nTypeSelection = IGSELECTION_ADD;
	else if (::GetKeyState (VK_CONTROL) < 0)
		nTypeSelection = IGSELECTION_REMOVE;
	m_pFrame->ManageSelection (IGSELECTION_SQUARE | nTypeSelection, &spVarArray);
	return 0L;
}
CComSafeArray<BSTR> convertVector2CCOMSafeArray(Result x)
{
\
	CComSafeArray<BSTR> result;

	for (std::string inst : x)
	{
		result.Add(convertstdSTR2BSTR(inst));
	}
	return result;

}
Beispiel #3
0
STDMETHODIMP CLDAPQuery::explodeDn(
	/* [in] */ BSTR str,
	/* [in] */ ULONG notypes,
	/* [retval][out] */ SAFEARRAY **result)
{
	PTCHAR *vals = ldap_explode_dn(CComBSTR(str), notypes);
	m_errorCode = LdapGetLastError();
	if(vals)
	{
		CComSafeArray<VARIANT> dnValues;
		for(LONG i = 0L; vals[i]!=NULL; i++)
		{
			dnValues.Add(CComVariant(vals[i]));
		}
		ldap_value_free(vals);
		*result = dnValues.Detach();
	}
	return S_OK;
}
Beispiel #4
0
STDMETHODIMP CTextSearch::GetResults(SAFEARRAY ** files)
{
	// TODO: Add your implementation code here
	Search searchService;
	std::string path = searchService.ConvertBSTRToMBS(_searchPath);
	//std::string keyword = searchService.ConvertBSTRToMBS(_searchKeyword);
	std::vector<std::string> keywords;

	for (int i = 0; i < (int)_searchKeywords.GetCount(); ++i)
		keywords.push_back(searchService.ConvertBSTRToMBS(_searchKeywords[i].Copy()));

	std::vector<std::string> results = searchService.StartTextSearch(keywords, path, _searchAll);
	CComSafeArray<BSTR> temp;
	
	for (auto result : results)
		temp.Add(CComBSTR(result.c_str()));

	*files = temp.Detach();

	return S_OK;
}
Beispiel #5
0
bool XlLibraryInitialize(XlAddInExportInfo* pExportInfo)
{
	HRESULT hr;
	CComPtr<ICorRuntimeHost> pHost;

	hr = LoadClr20(&pHost);
	if (FAILED(hr) || pHost == NULL)
	{
		// LoadClr20 shows diagnostic MessageBoxes if needed.
		// Perhaps remember that we are not loaded?
		return 0;
	}

	// If all is fine now, also start the CLR (always safe to do again.
	hr = pHost->Start();
	if (FAILED(hr))
	{
		ShowMessage(IDS_MSG_HEADER_NEEDCLR20, 
					IDS_MSG_BODY_HOSTSTART,
					IDS_MSG_FOOTER_UNEXPECTED,
					hr);
		return 0;
	}

	CString addInFullPath = AddInFullPath();

	CPath xllDirectory(addInFullPath);
	xllDirectory.RemoveFileSpec();

	CComPtr<IUnknown> pAppDomainSetupUnk;
	hr = pHost->CreateDomainSetup(&pAppDomainSetupUnk);
	if (FAILED(hr) || pAppDomainSetupUnk == NULL)
	{
		ShowMessage(IDS_MSG_HEADER_APPDOMAIN, 
					IDS_MSG_BODY_APPDOMAINSETUP, 
					IDS_MSG_FOOTER_UNEXPECTED,
					hr);
		return 0;
	}

	CComQIPtr<IAppDomainSetup> pAppDomainSetup = pAppDomainSetupUnk;

	hr = pAppDomainSetup->put_ApplicationBase(CComBSTR(xllDirectory));
	if (FAILED(hr))
	{
		ShowMessage(IDS_MSG_HEADER_APPDOMAIN, 
					IDS_MSG_BODY_APPLICATIONBASE, 
					IDS_MSG_FOOTER_UNEXPECTED,
					hr);
		return 0;
	}
	
	CComBSTR configFileName = addInFullPath;
	configFileName.Append(L".config");
	pAppDomainSetup->put_ConfigurationFile(configFileName);

	CComBSTR appDomainName = L"ExcelDna: ";
	appDomainName.Append(addInFullPath);
	pAppDomainSetup->put_ApplicationName(appDomainName);

	IUnknown *pAppDomainUnk = NULL;
	hr = pHost->CreateDomainEx(appDomainName, pAppDomainSetupUnk, 0, &pAppDomainUnk);
	if (FAILED(hr) || pAppDomainUnk == NULL)
	{
		ShowMessage(IDS_MSG_HEADER_APPDOMAIN, 
					IDS_MSG_BODY_APPDOMAIN, 
					IDS_MSG_FOOTER_UNEXPECTED,
					hr);
		return 0;
	}

	CComQIPtr<_AppDomain> pAppDomain(pAppDomainUnk);

	// Load plan for ExcelDna.Loader:
	// Try AppDomain.Load with the name ExcelDna.Loader.
	// Then if it does not work, we will try to load from a known resource in the .xll.

	CComPtr<_Assembly> pExcelDnaLoaderAssembly;
	hr = pAppDomain->Load_2(CComBSTR(L"ExcelDna.Loader"), &pExcelDnaLoaderAssembly);
	if (FAILED(hr) || pExcelDnaLoaderAssembly == NULL)
	{
		HRSRC hResInfoLoader = FindResource(hModuleCurrent, L"EXCELDNA_LOADER", L"ASSEMBLY");
		if (hResInfoLoader == NULL)
		{
			ShowMessage(IDS_MSG_HEADER_APPDOMAIN, 
						IDS_MSG_BODY_MISSINGEXCELDNALOADER, 
						IDS_MSG_FOOTER_UNEXPECTED,
						hr);
			return 0;
		}
		HGLOBAL hLoader = LoadResource(hModuleCurrent, hResInfoLoader);
		void* pLoader = LockResource(hLoader);
		ULONG sizeLoader = (ULONG)SizeofResource(hModuleCurrent, hResInfoLoader);
		
		CComSafeArray<BYTE> bytesLoader;
		bytesLoader.Add(sizeLoader, (byte*)pLoader);

		hr = pAppDomain->Load_3(bytesLoader, &pExcelDnaLoaderAssembly);
		if (FAILED(hr))
		{
			ShowMessage(IDS_MSG_HEADER_APPDOMAIN, 
						IDS_MSG_BODY_EXCELDNALOADER, 
						IDS_MSG_FOOTER_UNEXPECTED,
						hr);
			return 0;
		}

		CComBSTR pFullName;
		hr = pExcelDnaLoaderAssembly->get_FullName(&pFullName);
		if (FAILED(hr))
		{
			ShowMessage(IDS_MSG_HEADER_APPDOMAIN, 
						IDS_MSG_BODY_EXCELDNALOADERNAME, 
						IDS_MSG_FOOTER_UNEXPECTED,
						hr);
			return 0;
		}
	}
	
	CComPtr<_Type> pXlAddInType;
	hr = pExcelDnaLoaderAssembly->GetType_2(CComBSTR(L"ExcelDna.Loader.XlAddIn"), &pXlAddInType);
	if (FAILED(hr) || pXlAddInType == NULL)
	{
		ShowMessage(IDS_MSG_HEADER_APPDOMAIN, 
					IDS_MSG_BODY_XLADDIN, 
					IDS_MSG_FOOTER_UNEXPECTED,
					hr);
		return 0;
	}

	CComSafeArray<VARIANT> initArgs;
	initArgs.Add(CComVariant((INT32)pExportInfo));
	initArgs.Add(CComVariant((INT32)hModuleCurrent));
	initArgs.Add(CComVariant(addInFullPath.AllocSysString()));
	CComVariant initRetVal;
	CComVariant target;
	hr = pXlAddInType->InvokeMember_3(CComBSTR("Initialize"), (BindingFlags)(BindingFlags_Static | BindingFlags_Public | BindingFlags_InvokeMethod), NULL, target, initArgs, &initRetVal);
	if (FAILED(hr))
	{
		ShowMessage(IDS_MSG_HEADER_APPDOMAIN, 
					IDS_MSG_BODY_XLADDININIT, 
					IDS_MSG_FOOTER_UNEXPECTED,
					hr);
		return 0;
	}

	pHost_ForUnload = pHost.Detach();
	pAppDomain_ForUnload = (IUnknown*)pAppDomain.Detach();

	return initRetVal.boolVal == 0 ? false : true;
}