void CVideoFrame::OnPrepare(TNotifyUI& msg) { CVerticalLayoutUI* pVideoLayoutUI = static_cast<CVerticalLayoutUI*>(m_PaintManager.FindControl(_T("videoViewLayout"))); if (pVideoLayoutUI) { CDuiRect rcWindow; GetWindowRect(m_hWnd, &rcWindow); rcWindow.top += 80; LONG height = rcWindow.bottom - rcWindow.top; LONG width = rcWindow.right - rcWindow.left; int nControlWidth = pVideoLayoutUI->GetFixedWidth();//pActiveXUI->GetWidth(); int nControlHeight = pVideoLayoutUI->GetFixedHeight();//pActiveXUI->GetHeight(); RECT posRect; posRect = rcWindow; posRect.top = (height - nControlHeight)/2; posRect.left= (width - nControlWidth) /2; posRect.bottom = posRect.top + nControlHeight; posRect.right = posRect.left + nControlWidth; pVideoLayoutUI->SetVisible(true); pVideoLayoutUI->SetPos(posRect); } CWebBrowserUI* pActiveXUI = static_cast<CWebBrowserUI*>(m_PaintManager.FindControl(_T("htmlView"))); if( pActiveXUI ) { pActiveXUI->SetVisible(true); pActiveXUI->SetDelayCreate(true); CWebEventHandlerEx *pWebHandle = new CWebEventHandlerEx; pActiveXUI->SetWebBrowserEventHandler(pWebHandle); //这行代码,如果注释掉,就不会去掉边框,IE有bug,第二次加载网页才会让事件处理器有效 pActiveXUI->Navigate2(L"about:blank"); std::wstring strHtml = CPaintManagerUI::GetInstancePath() + _T("UIRes\\html\\video.html"); pActiveXUI->Navigate2(strHtml.c_str()); //pActiveXUI->Navigate2(L"http://www.baidu.com/"); } }
int CMainWnd::CreateNewTab(int nIndex, LPCTSTR pstrUrl) { TabInfo* pInfo = new TabInfo(); pInfo->nID = m_nTabID++; CBrowserTab* pTab = new CBrowserTab(); pTab->SetName(_T("browsertab")); m_pBrowserTabBar->AddAt(pTab, nIndex); pTab->SetAttribute(_T("style"), _T("tabbtn_style")); CWebBrowserUI* pWeb = new CWebBrowserUI(); m_pBrowserTabBody->AddAt(pWeb, nIndex); pWeb->SetHomePage(_T("about:blank")); pWeb->SetAutoNavigation(true); pWeb->SetDelayCreate(false); pWeb->SetWebBrowserEventHandler(this); if(pstrUrl == NULL) { lstrcpy(pInfo->szUrl, _T("about:blank")); lstrcpy(pInfo->szTitle, _T("空白页")); pTab->SetText(_T("空白页")); } else { lstrcpy(pInfo->szUrl, pstrUrl); lstrcpy(pInfo->szTitle, pstrUrl); pTab->SetText(pstrUrl); pWeb->Navigate2(pstrUrl); } pInfo->pTab = pTab; pInfo->pWebBrowser = pWeb; m_vTabs.push_back(pInfo); return nIndex; }