Example #1
0
LRESULT CAbout::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{

	POINT pt; 

	pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);

	RECT btnRect;

	CButtonUI* linkbtn;
	
	linkbtn = (CButtonUI*)m_PaintManager.FindControl(_T("www.131qz.com"));

	if (linkbtn != NULL)
	{

		btnRect = linkbtn->GetPos();

		if(pt.x > btnRect.left && pt.x < btnRect.right && pt.y > btnRect.top && pt.y < btnRect.bottom)
		{

			linkbtn->SetTextColor(0xffff0000);
			linkbtn->NeedUpdate();

		}else{

			linkbtn->SetTextColor(0xff0000ff);
			linkbtn->NeedUpdate();
		}

	}

	bHandled = FALSE;
	return 0;
}
Example #2
0
//点击选择表情
void CRightFrame::OnBnExpression()
{
	CLoveSendClassInExe* pGameFrame = static_cast<CLoveSendClassInExe*>(m_pRoom);
	CGameTalkText* pExpressWnd = &pGameFrame->m_ExpressWnd;

	//建立表情窗口
	if (pExpressWnd->GetSafeHwnd() == NULL)
	{
		pExpressWnd->CreateExpressionWnd(pGameFrame);
	}

	//移动窗口

	CButtonUI* pFaceBtn = static_cast<CButtonUI*>(m_pm.FindControl("Talk_Btn_Face"));
	RECT rcFaceBtn = pFaceBtn->GetPos();

	RECT rcRightWnd;
	RECT rcGameWnd;
	::GetWindowRect(m_hWnd,&rcRightWnd);
	::GetWindowRect(pGameFrame->m_hWnd,&rcGameWnd);

	::CSize siExpress;
	pExpressWnd->GetFixSize(siExpress);

	pGameFrame->SafeMoveWindow(pExpressWnd,
		(rcRightWnd.left + rcFaceBtn.right) - siExpress.cx + 176,
		rcRightWnd.top + rcFaceBtn.top - siExpress.cy - 3,
		siExpress.cx,siExpress.cy);

	pExpressWnd->ShowWindow(SW_SHOW);
	pExpressWnd->SetFocus();

}
 void CLoginWindow::Login(const CString& email,const CString& pwd,bool isMD5,bool isKeepLogin)
 {
	 spUserContextT pContext = theRuntimeState->GetCurrentContext(NULL);
	 spLogonUserInfoT theUser = pContext->GetUser();
	 if(theUser && 0 == theUser->sLogonEmail.CompareNoCase(email))
	 {
		 CControlUI *pCtl = GetPaintMgr()->FindControl(_T("login"));
		 CButtonUI  *pLoginBtn = static_cast<CButtonUI*>(pCtl);
		 assert(pLoginBtn);
		 if(pLoginBtn)
			CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T("Óû§ÒѾ­µÇ¼!!!"));
		 return;
	 }

	 CControlUI *pEmailEdit = GetPaintMgr()->FindControl(_T("email"));
	 if(pEmailEdit)
	 {
		 pEmailEdit->SetText(email);
	 }

	 std::string sUtf8UserName = em_utility::mci::unicode_2_utf8(email);
	 std::string sUtf8Password = em_utility::mci::unicode_2_utf8(pwd);
	 std::string sUtf8PasswordMD5 = (isMD5 ? sUtf8Password : em_utility::md5_checksum::get_md5((const unsigned char*)sUtf8Password.c_str(),(unsigned int)sUtf8Password.length()));

	 m_sUserName    = email;
	 m_sPasswordMd5 = em_utility::mci::utf8_2_CString(sUtf8PasswordMD5.c_str());
	 //m_isKeepLogin  = isKeepLogin;
	 
	 EnableWindow(FALSE);
//	 theWebServiceMgr->AsynSendRequest(m_hWnd,url::Requester::MakeLogin2(sUtf8UserName,sUtf8PasswordMD5));
//  	 CurlData* pData = new CurlData;
//  	 pData->SetURL("http://localhost/YMusic/login.php");
// 	 pData->n_type = url::WSRT_LOGIN;
// 	std::string sparam;
// 	sparam = "email=";
// 	sparam += sUtf8UserName;
// 	sparam += "&";
// 	sparam += "password=";
// 	sparam += sUtf8PasswordMD5;
// 	pData->SetData(sparam.c_str());

//	HttpManagerProto::Instance()->DoHttpPost(pData);
// 	CHttpThread* pthread = new CHttpThread(pData,m_hWnd,WM_WEB_SERVICE);
// 	pthread->Start();

	 CHttpCenter::Instance()->MakeLogin(sUtf8UserName,sUtf8PasswordMD5);

 }
/*
void CLoginWindow::OnWebService(void *pRequest ,void *pProto)
{
	url::CRequest *theRequest = (url::CRequest *)pRequest;
	LogonUserInfoT * theUser = static_cast<LogonUserInfoT*>(pProto);
	if(url::WSRT_LOGIN != theRequest->GetRequestType() &&
		url::WSRT_WEBLOGIN != theRequest->GetRequestType())
 		return;
	CControlUI *pCtl = GetPaintMgr()->FindControl(_T("login"));
	CButtonUI  *pLoginBtn = static_cast<CButtonUI*>(pCtl);
 	if(theRequest->IsTimeOut())
	{
		if(pLoginBtn)
			CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T("µÇ¼³¬Ê±£¬ÇëÖØÊÔ¡£"));
		EnableWindow(TRUE);
		return;
	}
	spLogonUserInfoT  spLogonUserInfo(new LogonUserInfoT(*theUser));
	
	if (!spLogonUserInfo)
	{	
		if(pLoginBtn)
			CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T("      µÇ¼ʧ°Ü£¬Óû§Ãû»òÃÜÂë´íÎó!      "));
		EnableWindow(TRUE);
		return ;
	}
 	{	
		if(url::WSRT_WEBLOGIN != theRequest->GetRequestType())
		{
			spLogonUserInfo->sLogonEmail = m_sUserName;
			spLogonUserInfo->sPasswordMD5 = m_sPasswordMd5;
			//spLogonUserInfo->bKeepLogged = !!m_isKeepLogin;
		}else 
		{
			assert(!spLogonUserInfo->sLogonEmail.IsEmpty());
			assert(!spLogonUserInfo->sPasswordMD5.IsEmpty());
			//spLogonUserInfo->bKeepLogged = true;
		}

		CControlUI *pCheckBox   = GetPaintMgr()->FindControl(_T("KeepLogin"));
		CCheckBoxUI *pKeepLogin = static_cast<CCheckBoxUI*>(pCheckBox);
		bool autoLogin = pKeepLogin->GetCheck();
// 		if (url::WSRT_WEBLOGIN == pRequest->GetRequestType())
// 			autoLogin = true;
	    theConfigMgr->GetNormalConfig()->EnableAutoLogin(autoLogin);
		theConfigMgr->GetNormalConfig()->Save();


		if(theDbMgr->GetGlobalDBase()->GetUserInfo(mci::unicode_2_utf8(spLogonUserInfo->sUserID).c_str()))
			theDbMgr->GetGlobalDBase()->UpdateUserInfo(spLogonUserInfo);
		else
			theDbMgr->GetGlobalDBase()->AddUserInfo(spLogonUserInfo);

		theRuntimeState->SetUserInfo(spLogonUserInfo);	

		RECT rtWin;
		::GetWindowRect(theMainWin->GetHWND(),&rtWin);
		POINT rtPos = {rtWin.left+25,rtWin.top+35};
		::ScreenToClient(theMainWin->GetHWND(),&rtPos);

		CInfoWindow::ShowInfoWindow(theMainWin->GetHWND(),rtPos,_T("                           µÇ¼³É¹¦                           "));

		Close(IDOK);
	}

//	CurlData* pdata = (CurlData*)pRequest;
//	int* nRet = (int*)pProto;
}
*/
void CLoginWindow::OnWebService(void *pRequest ,void *pProto)
{
	CControlUI *pCtl = GetPaintMgr()->FindControl(_T("login"));
	CButtonUI  *pLoginBtn = static_cast<CButtonUI*>(pCtl);
	CurlData* pdata = (CurlData*)pRequest;
	int* nRet = (int*)pProto;
	if (!pdata)
	{
		CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T("      µÇ¼ʧ°Ü£¬´íÎóÀàÐÍ[δ֪]!      "));
		EnableWindow(TRUE);
		return;
	}
	if(url::WSRT_LOGIN != pdata->n_type &&
		url::WSRT_WEBLOGIN != pdata->n_type)
	{
		CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T("      µÇ¼ʧ°Ü£¬´íÎóÀàÐÍ[·ÇWSRT_LOGIN]!      "));
		EnableWindow(TRUE);
		return;
	}

	static CResponseParser2 Parser;
	std::string xmlbuf;
	xmlbuf.assign(pdata->buffer);
	//	assert(!xmlbuf.empty());
	std::string bufLog = mci::utf8_2_ansi(xmlbuf.c_str());
	sLogWarn(bufLog.c_str());
	//modify by dfn.li 2014-01-17
	if(bufLog[0] == '?')
	{
		bufLog = bufLog.substr(1);
	}
	xmlbuf = mci::ansi_2_utf8(bufLog.c_str());

	int t_begin = clock();
	void *pResponse = NULL;
	pResponse = Parser.Parse(pdata->n_type,xmlbuf);
	int t_time = clock() - t_begin;

	LogonUserInfoT * theUser = static_cast<LogonUserInfoT*>(pResponse);
	if (!theUser)
	{
		if(pLoginBtn)
			CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T("      µÇ¼ʧ°Ü£¬Óû§Ãû»òÃÜÂë´íÎó!      "));
		EnableWindow(TRUE);
		return ;
	}
// 	if(theRequest->IsTimeOut())
// 	{
// 		if(pLoginBtn)
// 			CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T("µÇ¼³¬Ê±£¬ÇëÖØÊÔ¡£"));
// 		EnableWindow(TRUE);
// 		return;
// 	}
	spLogonUserInfoT  spLogonUserInfo(new LogonUserInfoT(*theUser));

	if (!spLogonUserInfo)
	{	
		if(pLoginBtn)
			CInfoWindow::ShowInfoWindow(this->m_hWnd,pLoginBtn->GetPos(),_T("      µÇ¼ʧ°Ü£¬Óû§Ãû»òÃÜÂë´íÎó!      "));
		EnableWindow(TRUE);
		return ;
	}
	{	
		if(url::WSRT_WEBLOGIN != pdata->n_type)
		{
			spLogonUserInfo->sLogonEmail = m_sUserName;
			spLogonUserInfo->sPasswordMD5 = m_sPasswordMd5;
			//spLogonUserInfo->bKeepLogged = !!m_isKeepLogin;
		}else 
		{
			assert(!spLogonUserInfo->sLogonEmail.IsEmpty());
			assert(!spLogonUserInfo->sPasswordMD5.IsEmpty());
			//spLogonUserInfo->bKeepLogged = true;
		}

		CControlUI *pCheckBox   = GetPaintMgr()->FindControl(_T("KeepLogin"));
		CCheckBoxUI *pKeepLogin = static_cast<CCheckBoxUI*>(pCheckBox);
		bool autoLogin = pKeepLogin->GetCheck();
		// 		if (url::WSRT_WEBLOGIN == pRequest->GetRequestType())
		// 			autoLogin = true;
		theConfigMgr->GetNormalConfig()->EnableAutoLogin(autoLogin);
		theConfigMgr->GetNormalConfig()->Save();


		if(theDbMgr->GetGlobalDBase()->GetUserInfo(mci::unicode_2_utf8(spLogonUserInfo->sUserID).c_str()))
			theDbMgr->GetGlobalDBase()->UpdateUserInfo(spLogonUserInfo);
		else
			theDbMgr->GetGlobalDBase()->AddUserInfo(spLogonUserInfo);

		theRuntimeState->SetUserInfo(spLogonUserInfo);	

		RECT rtWin;
		::GetWindowRect(theMainWin->GetHWND(),&rtWin);
		POINT rtPos = {rtWin.left+25,rtWin.top+35};
		::ScreenToClient(theMainWin->GetHWND(),&rtPos);

		CInfoWindow::ShowInfoWindow(theMainWin->GetHWND(),rtPos,_T("                           µÇ¼³É¹¦                           "));
		EnableWindow(TRUE);
		Close(IDOK);
	}

}