Exemple #1
0
STDMETHODIMP CPDPath::insertSubPath(long index, IPDSubPath *subPath)
{
	if (subPath == NULL) return E_INVALIDARG;

	CComObject<CPDSubPath>* pSubPath = (CComObject<CPDSubPath>*)subPath;

	pSubPath->AddRef();

// Remove first from previous path
	if (pSubPath->m_pOwnerPath != NULL)
	{
		pSubPath->m_pOwnerPath->removeSubPath(pSubPath);
	}

	pSubPath->m_pOwnerPath = this;

	DWORD cookie;
	pSubPath->Advise(this, &cookie);

	if (index < 0)
		m_subPaths.Add(pSubPath);
	else
		m_subPaths.InsertAt(index, pSubPath);

	FireOnChanged(NOTIFY_ADD, pSubPath->GetUnknown(), DISPID_UNKNOWN);

	return S_OK;
}
Exemple #2
0
HRESULT CPDPath::parseString(BSTR s)
{
	WCHAR* p = s;

	while (*p)
	{
		CComObject<CPDSubPath>* pSubPath;
		CComObject<CPDSubPath>::CreateInstance(&pSubPath);
		if (pSubPath)
		{
			pSubPath->AddRef();

			p = pSubPath->parseString(p);
			if (p)
			{
				pSubPath->AddRef();
				pSubPath->m_pOwnerPath = this;

				DWORD cookie;
				pSubPath->Advise(this, &cookie);

				m_subPaths.Add(pSubPath);
			}

			pSubPath->Release();

			if (p == NULL)
			{
				MessageBox(NULL, "Failed to parse path", "", MB_OK);
				return E_FAIL;
			}
		}
	}

	return S_OK;
}