BOOL CFlashManager::ResetAllFlashCallbacks(IHTMLDocument2* pDoc) { CFuncLog log(g_pLog, "CFlashManager::ResetAllFlashCallbacks()"); KillTimer(IDT_FLASH_TIMER); m_bFlashTimerInUse = false; KillTimer(IDT_PASTE_TIMER); m_bPasteTimerInUse = false; CComQIPtr<IHTMLDocument2> spHTML(pDoc); if (!spHTML) return FALSE; if (GetFlashElements(spHTML)) { ELEMENTLIST::iterator itr; itr = m_FlashElementList.begin(); while(itr != m_FlashElementList.end()) { //SetMouseOverCallback(*itr, TRUE); SetDragEndCallback(*itr, TRUE); itr++; } } m_FlashElementList.clear(); return TRUE; }
void CIECanvas::UpdateUIHandler() { CComPtr<IDispatch> m_spDoc; if (m_spBrowser) m_spBrowser->get_Document(&m_spDoc); if (m_spDoc) { // make shure this really is a HTML document CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spHTML(m_spDoc); CComQIPtr<ICustomDoc, &IID_ICustomDoc> spCustomDoc(m_spDoc); if (spHTML && spCustomDoc) { spCustomDoc->SetUIHandler(m_pIE4Events); //printf("setting new UIHandler on document..\n"); } } }
BOOL CFlashManager::ShowMenu(IHTMLDocument2* pDoc, BOOL bShow) { CComQIPtr<IHTMLDocument2> spHTML(pDoc); if (!spHTML) return FALSE; if (GetFlashElements(spHTML)) { ELEMENTLIST::iterator itr; itr = m_FlashElementList.begin(); while(itr != m_FlashElementList.end()) { if (!Flash_ShowMenu((*itr).pFlashDisp, bShow)) return FALSE; itr++; } } return TRUE; }
BOOL CFlashManager::SetAllFlashAttributes(IHTMLDocument2* pDoc, BOOL bContentEditable) { CFuncLog log(g_pLog, "CFlashManager::SetAllFlashAttributes()"); // This function sets the contentEditable attribute for Flash elements. // By default the current flash elements are retrieved from pDoc and // the contentEditable value is set to "true". This behavior is overriden // by the bEdit and pElist parameters. CComQIPtr<IHTMLDocument2> spHTML(pDoc); if (!spHTML) return false; ELEMENTLIST::iterator itr; itr = m_FlashElementList.begin(); while(itr != m_FlashElementList.end()) { SetFlashAttributes(*itr, bContentEditable); itr++; } return true; }
BOOL CFlashManager::Enable(IHTMLDocument2* pDoc, BOOL bContentEditable) { CFuncLog log(g_pLog, "CFlashManager::Enable()"); CComQIPtr<IHTMLDocument2> spHTML(pDoc); if (spHTML && m_hWnd) { KillTimer(IDT_FLASH_TIMER); m_bWSShellUsed = true; // assume true to use as default. m_bFlashTimerInUse = false; if (GetFlashElements(spHTML)) { SetAllFlashAttributes(spHTML, bContentEditable); SetTimer(IDT_FLASH_TIMER, 200, NULL); m_bFlashTimerInUse = true; log.LogString(LOG_INFO, "SUCCESS"); return TRUE; } } log.LogString(LOG_WARNING, "No Flash Elements?"); return FALSE; }
BOOL CFlashManager::GetFlashElements(IHTMLDocument2* pDoc) { CFuncLog log(g_pLog, "CFlashManager::GetFlashElements()"); m_FlashElementList.clear(); CComQIPtr<IHTMLDocument2> spHTML(pDoc); if (!spHTML) { CString szMsg; szMsg.Format("CComQIPtr<IHTMLDocument2> spHTML(pDoc) FAILED: pDoc==%X", pDoc); GetError(szMsg); log.LogString(LOG_ERROR, szMsg.GetBuffer()); return FALSE; } CComPtr<IHTMLElementCollection> spAll; HRESULT hr = spHTML->get_all(&spAll); if (FAILED(hr) || !spAll) { CString szMsg; szMsg.Format("spHTML->get_all(&spAll) FAILED: HR == [%X], spAll == %X", hr, spAll); GetError(szMsg); log.LogString(LOG_ERROR, szMsg.GetBuffer()); return FALSE; } // Find all the OBJECT tags in the document CComPtr<IDispatch> spTagsDisp; hr = spAll->tags(CComVariant(CComBSTR("object")), &spTagsDisp); if (FAILED(hr) || !spTagsDisp) { CString szMsg; szMsg.Format("if (FAILED(hr) || !spTagsDisp) FAILED: hr==%X", hr, spTagsDisp); GetError(szMsg); log.LogString(LOG_ERROR, szMsg.GetBuffer()); return FALSE; } CComQIPtr<IHTMLElementCollection> spTags(spTagsDisp); if (!spTags) return FALSE; long nCnt = 0; hr = spTags->get_length(&nCnt); if (FAILED(hr)) { CString szMsg; szMsg.Format("spTags->get_length(&nCnt) FAILED: nCnt==%d", nCnt); log.LogString(LOG_WARNING, szMsg.GetBuffer()); return FALSE; } bool bSuccess = false; for (long i=0; i < nCnt; i++) { CComPtr<IDispatch> spTagDisp; hr = spTags->item(CComVariant(i), CComVariant(i), &spTagDisp); if (FAILED(hr) || !spTagDisp) continue; CComQIPtr<IHTMLObjectElement> spObject(spTagDisp); if (!spObject) continue; CComBSTR bsClassID; hr = spObject->get_classid(&bsClassID); CString szClassID(bsClassID); if (FAILED(hr) || !bsClassID) { CString szMsg; szMsg.Format("if (FAILED(hr) || !bsClassID) FAILED: hr==%X, bsClassID == %s", hr, bsClassID.m_str); log.LogString(LOG_ERROR, szMsg.GetBuffer()); continue; } szClassID.MakeUpper(); if (szClassID.Find(FLASH_PLAYER_CLASSID) >= 0) { log.LogString(LOG_INFO, "if (szClassID.Find(FLASH_PLAYER_CLASSID) >= 0) is TRUE"); ElementInfo ElemInfo; ElemInfo.Updated = FALSE; CComPtr<IDispatch> spFlashDisp; hr = spObject->get_object(&spFlashDisp); if (SUCCEEDED(hr) && spFlashDisp) { ElemInfo.pFlashDisp = spFlashDisp; log.LogString(LOG_INFO, "if (SUCCEEDED(hr) && spFlashDisp) Succeeded"); } ElemInfo.pTagDisp = spTagDisp; m_FlashElementList.push_back(ElemInfo); bSuccess = true; } } if (g_pLog) { CString szMsg; szMsg.Format("RESULTS: bSuccess == %X, nCnt==%d", bSuccess, nCnt); log.LogString(LOG_INFO, szMsg.GetBuffer()); } return bSuccess; }