Пример #1
0
void main_frame::OnAuthSuccess( VARIANT *&url )
{
	USES_CONVERSION;
	LPCTSTR lpstrAddress = (LPCTSTR)url->bstrVal;

	CDuiString str(lpstrAddress);

	int pos  = -1;
	pos = str.Find('=');

	CDuiString retnCode = str.Right(str.GetLength() - pos - 1);

	m_weiboManage.GetMethod()->oauth2Code(W2A(retnCode), REDIRECT_URL , NULL);

	CWebBrowserUI *pLoginWeb = static_cast<CWebBrowserUI*>(m_PaintManager.FindControl(_T("loginWnd")));
	if (pLoginWeb)
	{
		pLoginWeb->SetVisible(false);
	}

	CLabelUI *pUnReadTimelineCount = static_cast<CLabelUI*>(m_PaintManager.FindControl(_T("unreadTimelineCount")));
	if (pUnReadTimelineCount)
	{
		m_PaintManager.SetTimer(pUnReadTimelineCount,1,1000*10);
	}
}
Пример #2
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);
	}

}
Пример #3
0
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/");
	}
}