HRESULT vmsDomHelper::GetParentDocument(IHTMLDocument2 *pDoc, IHTMLDocument2 **ppParentDoc)
{
	*ppParentDoc = NULL;

	ATLASSERT (pDoc != NULL);
	if (!pDoc)
		return E_INVALIDARG;

	IHTMLWindow2Ptr spWnd;
	HRESULT hr = pDoc->get_parentWindow (&spWnd);
	if (FAILED (hr))
		return hr;

	IHTMLWindow2Ptr spWndParent;
	hr = spWnd->get_parent (&spWndParent);
	if (FAILED (hr))
		return hr;

	hr = spWndParent->get_document (ppParentDoc);
	if (hr == E_ACCESSDENIED)
	{
		IWebBrowser2Ptr spWB;
		hr = GetWebBrowser (spWndParent, &spWB);
		if (FAILED (hr))
			return E_ACCESSDENIED;
		IDispatchPtr spdDoc;
		hr = spWB->get_Document (&spdDoc);
		if (FAILED (hr))
			return hr;
		hr = spdDoc->QueryInterface (IID_IHTMLDocument2, (void**)ppParentDoc);
	}
	if (FAILED (hr))
		return hr;

	IUnknownPtr spUnk1 (pDoc);
	IUnknownPtr spUnk2 (*ppParentDoc);
	if (pDoc == *ppParentDoc || spUnk1 == spUnk2)
	{
		(*ppParentDoc)->Release ();
		*ppParentDoc = NULL;
	}

	return S_OK;
}
Exemple #2
0
void vmsFlashHelper::GetFlashMoviesObjList(IHTMLDocument2Ptr spDoc, LPFLASHLIST pv, BOOL bIncludingFrames)
{
	
    GetFlashMoviesObjList_noframes (spDoc, pv);

	if (bIncludingFrames == FALSE)
		return;

    
    IHTMLFramesCollection2Ptr spFrames;
	spDoc->get_frames (&spFrames);
	if (spFrames == NULL)
		return;

	long lCount = 0;
	spFrames->get_length (&lCount);

	for (long i = 0; i < lCount; i++)
	{
		CComVariant va ((long)i);
		CComVariant vaR;

		spFrames->item (&va, &vaR);

		if (vaR.pdispVal != NULL)
		{
			IHTMLWindow2Ptr spWnd = vaR.pdispVal;
			if (spWnd != NULL)
			{
				IHTMLDocument2Ptr spFDoc;
				spWnd->get_document (&spFDoc);
				if (spFDoc != NULL)
					GetFlashMoviesObjList (spFDoc, pv, TRUE);
			}
		}
	}
}
Exemple #3
0
void vmsFlashHelper::SaveFlashMovies(IHTMLDocument2Ptr spDoc, LPCSTR pszFolder, BOOL bIncludingFrames)
{
    SaveFlashMovies_noframes(spDoc, pszFolder);

	if (bIncludingFrames == FALSE)
		return;

    
    IHTMLFramesCollection2Ptr spFrames;
	spDoc->get_frames (&spFrames);
	if (spFrames == NULL)
		return;

	long lCount = 0;
	spFrames->get_length (&lCount);

	for (long i = 0; i < lCount; i++)
	{
		CComVariant va ((long)i);
		CComVariant vaR;

		spFrames->item (&va, &vaR);

		if (vaR.pdispVal != NULL)
		{
			IHTMLWindow2Ptr spWnd = vaR.pdispVal;
			if (spWnd != NULL)
			{
				IHTMLDocument2Ptr spFDoc;
				spWnd->get_document (&spFDoc);
				if (spFDoc != NULL)
					SaveFlashMovies (spFDoc, pszFolder, TRUE);
			}
		}
	}
}
Exemple #4
0
void CJSOpenView::OnFileWindowOpen() {
	HRESULT hr;
	CString str;
	try {
		CComQIPtr<IHTMLDocument2> document = GetHtmlDocument();
		if (document != NULL) {
			IHTMLWindow2Ptr window;
			document->get_parentWindow(&window);
			if (window != NULL) {
				CComBSTR url;
				document->get_URL(&url);

				CComPtr<IHTMLWindow2> newwin;
				if (FAILED(hr = window->open(url, CComBSTR(L"_blank"), CComBSTR(), false, &newwin))) {
					_com_issue_errorex(hr, window, IID_IHTMLWindow2);
				}
				printf("");
			}
		}
	}
	catch (_com_error err) {
		AfxMessageBox(CString(err.ErrorMessage()), MB_ICONEXCLAMATION);
	}
}