Ejemplo n.º 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;
}
Ejemplo n.º 2
0
void CMDriveDlg::OnAdvise()
{
	if (m_nAdviseCnt < m_nMaxAdvises)
	{
		CComObject<CDriver>* pDriver;
		CComObject<CDriver>::CreateInstance(&pDriver);
		pDriver->m_nID = m_nAdviseCnt;
		HRESULT hRes = AtlAdvise(pRandom, pDriver->GetUnknown(), IID_IRandomEvent, &m_arrAdvise[m_nAdviseCnt++]);
		if (FAILED(hRes))
		{
			AfxMessageBox("Advise failed");
			m_nAdviseCnt--;
		}
	}
	else
		AfxMessageBox("No more advises");
}
Ejemplo n.º 3
0
HRESULT CExplorerCommandProvider::_GetCommand(HMENU hMenu, UINT uMenuID, REFIID riid, LPVOID* ppRetVal)
{
   // NOTE: We grab the menu-information here, including its title. The string
   //       buffer is local and since we intend to store a copy for each Command item
   //       we'll have to transfer the text to a buffer there too.
   WCHAR wszTitle[100] = { 0 };
   MENUITEMINFO mii = { 0 };
   mii.cbSize = sizeof(mii);
   mii.fMask = MIIM_ID | MIIM_FTYPE | MIIM_STATE | MIIM_STRING | MIIM_SUBMENU;
   mii.dwTypeData = wszTitle;
   mii.cch = lengthof(wszTitle) - 1;
   if( !::GetMenuItemInfo(hMenu, uMenuID, FALSE, &mii) ) return E_FAIL;
   CComObject<CExplorerCommand>* pCommand = NULL;
   HR( CComObject<CExplorerCommand>::CreateInstance(&pCommand) );
   CComPtr<IUnknown> spKeepAlive = pCommand->GetUnknown();
   HR( pCommand->Init(this, mii) );
   return pCommand->QueryInterface(riid, ppRetVal);
}
Ejemplo n.º 4
0
/*
** Set up the COM interface with WMP.
**
*/
void CPlayerWMP::Initialize()
{
	// Create windows class
	WNDCLASS wc = {0};
	wc.hInstance = g_Instance;
	wc.lpfnWndProc = DefWindowProc;
	wc.lpszClassName = L"NowPlayingWMPClass";
	RegisterClass(&wc);

	// Create the host window
	m_Window = CreateWindow(L"NowPlayingWMPClass",
							L"HostWindow",
							WS_DISABLED,
							CW_USEDEFAULT,
							CW_USEDEFAULT,
							CW_USEDEFAULT,
							CW_USEDEFAULT,
							NULL,
							NULL,
							g_Instance,
							NULL);

	if (!m_Window) return;

	CComPtr<IObjectWithSite> spHostObject;
	CComPtr<IAxWinHostWindow> spHost;
	CComObject<CRemoteHost>* pRemoteHost;

	m_AxWindow = new CAxWindow();
	HRESULT hr = m_AxWindow ? S_OK : E_OUTOFMEMORY;

	if (SUCCEEDED(hr)) 
	{
		m_AxWindow->Create(m_Window, NULL, NULL, WS_CHILD | WS_DISABLED);
		if(IsWindow(m_AxWindow->m_hWnd))
		{
			hr = m_AxWindow->QueryHost(IID_IObjectWithSite, (void**)&spHostObject);
			if(!spHostObject.p)
			{
				hr = E_POINTER;
			}
		}
	}
	else
	{
		return;
	}

	// Create remote host which implements IServiceProvider and IWMPRemoteMediaServices
	if (SUCCEEDED(hr))
	{
		hr = CComObject<CRemoteHost>::CreateInstance(&pRemoteHost);
		if (pRemoteHost)
		{
			pRemoteHost->AddRef();
			pRemoteHost->m_Player = this;
		}
		else
		{
			hr = E_POINTER;
		}
	}

	// Set site to the remote host
	if (SUCCEEDED(hr))
	{
		hr = spHostObject->SetSite((IWMPRemoteMediaServices*)pRemoteHost);
	}

	if (SUCCEEDED(hr))
	{
		hr = m_AxWindow->QueryHost(&spHost);
		if (!spHost)
		{
			hr = E_NOINTERFACE;
		}
	}

	// Create WMP control
	if (SUCCEEDED(hr))
	{
		hr = spHost->CreateControl(L"{6BF52A52-394A-11D3-B153-00C04F79FAA6}", m_AxWindow->m_hWnd, NULL);
	}

	if (SUCCEEDED(hr))
	{
		hr = m_AxWindow->QueryControl(&m_IPlayer);
		if (!m_IPlayer.p)
		{
			hr = E_NOINTERFACE;
		}
	}

	// Connect the event interface
	CComPtr<IConnectionPointContainer> spConnectionContainer;
	hr = m_IPlayer->QueryInterface(&spConnectionContainer);

	if (SUCCEEDED(hr))
	{
		hr = spConnectionContainer->FindConnectionPoint( __uuidof(IWMPEvents), &m_IConnectionPoint);
	}

	if (SUCCEEDED(hr))
	{
		DWORD adviseCookie;
		hr = m_IConnectionPoint->Advise(pRemoteHost->GetUnknown(), &adviseCookie);

		if ((FAILED(hr)) || !adviseCookie)
		{
			m_IConnectionPoint = NULL;
		}
	}

	// Release remote host object
	if (pRemoteHost)
	{
		pRemoteHost->Release();
	}

	hr = m_IPlayer->get_controls(&m_IControls);
	if (FAILED(hr)) return;

	hr = m_IPlayer->get_settings(&m_ISettings);
	if (FAILED(hr)) return;

	// Get player state
	WMPPlayState state;
	m_IPlayer->get_playState(&state);
	if (state == wmppsPlaying)
	{
		m_State = STATE_PLAYING;
	}
	else if (state ==  wmppsPaused)
	{
		m_State = STATE_PAUSED;
	}

	if (m_State != STATE_STOPPED)
	{
		m_TrackChanged = true;
	}

	m_Initialized = true;
}
Ejemplo n.º 5
0
void __stdcall CEXMLDocumentStyleSheetsView::OnItemDblClick(IUITreeItem* item)
{
	DWORD itemdata;
	m_treeCtl->GetItemInfo(item, &itemdata, NULL, NULL);

	CComQIPtr<ILDOMNode> node = (IUnknown*)itemdata;

	CComQIPtr<ILDOMElement> element = node;

	if (element)
	{
		CComPtr<IEElement> eElement;
		m_viewGroup->m_pDocument->GetEElementFromDOMElement(element, &eElement);

		CEStyleElement* pStyleElement = static_cast<CEStyleElement*>(eElement.p);

		CComQIPtr<ILLinkStyle> linkStyle = node;

		CComPtr<ILCSSStyleSheet> styleSheet;
		linkStyle->get_sheet((ILStyleSheet**)&styleSheet);

		{
			ASSERT(0);
#if 0
			CComQIPtr<ILXAddin> addin = m_viewGroup->m_pDocument->m_app;

			WCHAR buf[512];
			swprintf(buf, L"%s/style", (BSTR)m_viewGroup->m_pDocument->m_fileTitle);

			pStyleElement->m_pCSSDocument->m_fileTitle = buf;
			pStyleElement->m_pCSSDocument->m_app = addin;
			pStyleElement->m_pCSSDocument->m_styleSheet = styleSheet;

			CComPtr<ILXAddinSite> addinSite;
			addin->GetSite(&addinSite);

			CComPtr<ILXFrameworkFrame> lxframe;
			addinSite->GetFrame(&lxframe);

			CComQIPtr<IEFrame> eframe = lxframe;

			pStyleElement->m_pCSSDocument->ShowViews(eframe);
#endif
		}
	}

	CComQIPtr<ILLinkStyle> linkStyle = node;

	if (linkStyle)
	{
	}

#if 0
	CComPtr<ILCSSStyleSheet> openStyleSheet;

	CComQIPtr<ILCSSStyleSheet> styleSheet = (IUnknown*)itemdata;
	CComQIPtr<ILCSSRule> rule = (IUnknown*)itemdata;
	if (styleSheet)
	{
		CComBSTR href;
		styleSheet->get_href(&href);
		if (href.Length())
		{
			openStyleSheet = styleSheet;
		}
	}
	else if (rule)
	{
		CComQIPtr<ILCSSImportRule> importRule = rule;
		if (importRule)
		{
			importRule->get_styleSheet(&openStyleSheet);
		}
	}

	if (openStyleSheet)
	{
		CComObject<CECSSDocument>* pCSSDocument;
		CComObject<CECSSDocument>::CreateInstance(&pCSSDocument);
		if (pCSSDocument)
		{
			pCSSDocument->m_styleSheet = openStyleSheet;

			BSTR cssText;
			openStyleSheet->get_cssText(&cssText);
			pCSSDocument->m_textData->put_data(cssText);

#if 0
			AddDocument(pCSSDocument->GetUnknown(), NULL);
#endif
		}
	}
#endif
}