Beispiel #1
0
void main_frame::OnPrepare( TNotifyUI& msg )
{

	m_weiboManage.StartUp();
	m_layoutManage.SetPaintManage(&m_PaintManager);

	//m_weiboManage.m_pLayoutManage = &m_layoutManage;

	m_weiboManage.UpdateUserProfile = std::tr1::bind(&CLayoutManage::UpdateUserProfile,&m_layoutManage,_1,_2,_3);
	m_weiboManage.UpdateUnread = std::tr1::bind(&CLayoutManage::UpdateUnread,&m_layoutManage,_1);
	m_weiboManage.UpdateTimelineList = std::tr1::bind(&CLayoutManage::UpdateTimelineList,&m_layoutManage,_1,_2,_3,_4,_5);

	CRichEditUI *pWeiboCotent = static_cast<CRichEditUI*>(m_PaintManager.FindControl(_T("weiboContent")));
	if (pWeiboCotent)
	{
		pWeiboCotent->OnEvent += MakeDelegate(this,&main_frame::OnWeiboContentEvent);
		pWeiboCotent->OnNotify += MakeDelegate(this,&main_frame::OnWeiboContentNotify);
		pWeiboCotent->SetAutoURLDetect();
	}

	CWebBrowserUI *pLoginWeb = static_cast<CWebBrowserUI*>(m_PaintManager.FindControl(_T("loginWnd")));

	if (m_weiboManage.CheckExistUser())
	{
		m_weiboManage.InitWeibo();
		pLoginWeb->SetVisible(false);
	}
	else
	{
		CWebBrowserUI *pLoginWeb = static_cast<CWebBrowserUI*>(m_PaintManager.FindControl(_T("loginWnd")));
		if (pLoginWeb)
		{
			m_pWebBrowserEventHander = new CMagiccWebBrowserEventHandler;
			m_pWebBrowserEventHander->SetMainFrame(this);
			pLoginWeb->SetWebBrowserEventHandler(m_pWebBrowserEventHander);
			pLoginWeb->NavigateUrl(_T("https://api.weibo.com/oauth2/authorize?client_id=397065771&response_type=code&redirect_uri=www.baidu.com"));
		}
	}

	CLabelUI *pUnreadTimeline = static_cast<CLabelUI*>(m_PaintManager.FindControl(_T("unreadTimelineCount")));
	if (pUnreadTimeline)
	{
		pUnreadTimeline->OnEvent += MakeDelegate(this,&main_frame::OnRefreshUnReadTimeline);
		m_PaintManager.SetTimer(pUnreadTimeline,1,1000*10);
	}

}
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/");
	}
}
Beispiel #3
0
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;
}