Example #1
0
bool main_frame::OnWeiboContentNotify( void *param )
{
	TNotifyUI *pNotify = (TNotifyUI *)param;
	if (_tcsicmp(pNotify->pSender->GetName() ,  _T("weiboContent")) == 0)
	{
		CRichEditUI *pRichEdit = static_cast<CRichEditUI*>(pNotify->pSender);
		if (pRichEdit && (_tcsicmp(pNotify->sType,_T("richEditTxViewChanged")) == 0))
		{
			CDuiString strText = pRichEdit->GetText();
			int length = strText.GetLength();
			if (length < 140)
			{
				CDuiString strLimit;
				strLimit.Format(_T("%d"),140-length);
				CLabelUI *pLabel = static_cast<CLabelUI*>(m_PaintManager.FindControl(_T("limitTextLength")));
				if (pLabel)
				{
					pLabel->SetText(strLimit);
				}
			}
		}

	}	
	return true;
}
	BOOL CDuiAutoComplete::AddItem(const CDuiString& p_sItem, int iPos)
	{
		if (p_sItem.GetLength() != 0)
		{
			int oldpos=FindItem(p_sItem);
			if (oldpos == -1)
			{
				if (iPos == -1)
					m_sStringArrayMap.Add(new CDuiString(p_sItem));
				else
					m_sStringArrayMap.InsertAt(iPos,new CDuiString(p_sItem));

				while (m_sStringArrayMap.GetSize() > m_iMaxItemCount)
					m_sStringArrayMap.Remove(m_sStringArrayMap.GetSize() - 1,true);
				return TRUE;
			} else if (iPos!=-1) {
				m_sStringArrayMap.Remove(oldpos,true);
				if (oldpos<iPos) --iPos;
				m_sStringArrayMap.InsertAt(iPos,new CDuiString(p_sItem));

				while (m_sStringArrayMap.GetSize() > m_iMaxItemCount)
					m_sStringArrayMap.Remove(m_sStringArrayMap.GetSize() - 1,true);
				return TRUE;
			}
		}
		return FALSE;
	}
	BOOL CDuiAutoComplete::RemoveItem(const CDuiString& p_sItem)
	{
		if (p_sItem.GetLength() != 0)
		{
			int iPos = FindItem(p_sItem);
			if (iPos != -1)
			{
				m_sStringArrayMap.Remove(iPos,true);
				return TRUE;
			}
		}
		return FALSE;
	}
Example #4
0
	LRESULT CHotKeyWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
	{
		LRESULT lRes = 0;
		BOOL bHandled = TRUE;
		if( uMsg == WM_KILLFOCUS ) lRes = OnKillFocus(uMsg, wParam, lParam, bHandled);
		else if( uMsg == OCM_COMMAND ) {
			if( GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE ) lRes = OnEditChanged(uMsg, wParam, lParam, bHandled);
			else if( GET_WM_COMMAND_CMD(wParam, lParam) == EN_UPDATE ) {
				RECT rcClient;
				::GetClientRect(m_hWnd, &rcClient);
				::InvalidateRect(m_hWnd, &rcClient, FALSE);
			}
		}
		else if( uMsg == WM_KEYDOWN && TCHAR(wParam) == VK_RETURN ) {
			m_pOwner->GetManager()->SendNotify(m_pOwner, _T("return"));
		}
		else if ( (uMsg == WM_NCACTIVATE) || (uMsg == WM_NCACTIVATE) || (uMsg == WM_NCCALCSIZE) )
		{
			return 0;
		}
		else if (uMsg == WM_PAINT)
		{
			PAINTSTRUCT ps = { 0 };
			HDC hDC = ::BeginPaint(m_hWnd, &ps);
			DWORD dwTextColor = m_pOwner->GetTextColor();
			DWORD dwBkColor = m_pOwner->GetNativeBkColor();
			CDuiString strText = GetHotKeyName();
			::RECT rect;
			::GetClientRect(m_hWnd, &rect);
			::SetBkMode(hDC, TRANSPARENT);
			::SetTextColor(hDC, RGB(GetBValue(dwTextColor), GetGValue(dwTextColor), GetRValue(dwTextColor)));
			HBRUSH hBrush =  CreateSolidBrush( RGB(GetBValue(dwBkColor), GetGValue(dwBkColor), GetRValue(dwBkColor)) );
			::FillRect(hDC, &rect, hBrush);
			::DeleteObject(hBrush);
			HFONT hOldFont = (HFONT)SelectObject(hDC, GetWindowFont(m_hWnd));
			::SIZE size = { 0 };
			::GetTextExtentPoint32(hDC, strText.GetData(), strText.GetLength(), &size) ;
			::DrawText(hDC, strText.GetData(), -1, &rect, DT_LEFT|DT_SINGLELINE|DT_END_ELLIPSIS|DT_NOPREFIX);
			::SelectObject(hDC, hOldFont);
			::SetCaretPos(size.cx, 0);
			::EndPaint(m_hWnd, &ps);
			bHandled = TRUE;
		}
		else bHandled = FALSE;
		if( !bHandled ) return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
		return lRes;
	}
Example #5
0
void main_frame::OnAuthSuccess( CDuiString &strUrl )
{

	USES_CONVERSION;
	int pos  = -1;
	pos = strUrl.Find('=');

	CDuiString retnCode = strUrl.Right(strUrl.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);
	}
}
Example #6
0
void main_frame::Notify( TNotifyUI& msg )
{
	if( msg.sType == _T("windowinit") ) 
		OnPrepare(msg);
	else if (_tcsicmp(msg.sType,_T("click")) == 0)
	{
		if (_tcsicmp(msg.pSender->GetName(),_T("closebtn")) == 0 )
		{	
			Close();
		}
		else if (_tcsicmp(msg.pSender->GetName(),_T("minbtn")) == 0)
		{
			SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
		}
		else if (_tcsicmp(msg.pSender->GetName(),_T("maxbtn")) == 0)
		{
			SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
		}
		else if (_tcsicmp(msg.pSender->GetName(),_T("tagBtn")) == 0)
		{
			CRichEditUI *pRichEdit = static_cast<CRichEditUI*>(m_PaintManager.FindControl(_T("weiboContent")));
			if (pRichEdit)
			{
				CDuiString strText = _T("#²åÈëÄãµÄ»°Ìâ#");
				pRichEdit->SetText(strText);
				pRichEdit->SetSel(1,7);
				pRichEdit->SetFocus();
				
				CLabelUI *plabel = static_cast<CLabelUI*>(m_PaintManager.FindControl(_T("defaultShowText")));
				if (plabel)
				{
					plabel->SetVisible(false);
				}
				
			}
		}
		else if (_tcsicmp(msg.pSender->GetName(),_T("sendWeiboBtn")) == 0)
		{
			CRichEditUI *pRichEdit = static_cast<CRichEditUI*>(m_PaintManager.FindControl(_T("weiboContent")));
			if (pRichEdit)
			{
				CDuiString strWeibo = pRichEdit->GetText();
				if (strWeibo.GetLength() > 0)
				{
					DWORD dwNum = WideCharToMultiByte(CP_UTF8,NULL,strWeibo,-1,NULL,0,NULL,FALSE);
					char *psText;
					psText = new char[dwNum];
					if(!psText)
					{
						delete []psText;
					}
					WideCharToMultiByte (CP_UTF8,NULL,strWeibo,-1,psText,dwNum,NULL,FALSE);
					m_weiboManage.PostNewWeibo(psText);

					delete []psText;

					pRichEdit->SetText(_T(""));
				}
			}
		}
		else if (_tcsicmp(msg.pSender->GetName(),_T("refreshBtn")) == 0)
		{
			m_weiboManage.RefreshTimeline();
		}
	}
	
}
Example #7
0
bool main_frame::OnWeiboContentEvent( void *param )
{
	TEventUI *pEvent = (TEventUI*)param;
	if (pEvent->Type == UIEVENT_SETFOCUS )
	{
		CHorizontalLayoutUI *pWeiboCotentContainer = static_cast<CHorizontalLayoutUI*>(m_PaintManager.FindControl(_T("weiboContentContainer")));
		if (pWeiboCotentContainer)
		{
			pWeiboCotentContainer->SetBorderColor(RGB(0,0,255));
		}
		CRichEditUI *pRichEdit = static_cast<CRichEditUI*>(pEvent->pSender);
		if (pRichEdit)
		{
			CDuiString strText = pRichEdit->GetText();
			if (strText.GetLength() == 0)
			{
				CLabelUI *plabel = static_cast<CLabelUI*>(m_PaintManager.FindControl(_T("defaultShowText")));
				if (plabel)
				{
					plabel->SetVisible(false);
				}
			}
		}
	}
	else if (pEvent->Type == UIEVENT_KILLFOCUS )
	{
		CHorizontalLayoutUI *pWeiboCotentContainer = static_cast<CHorizontalLayoutUI*>(m_PaintManager.FindControl(_T("weiboContentContainer")));
		if (pWeiboCotentContainer)
		{
			pWeiboCotentContainer->SetBorderColor(RGB(204,204,204));
		}
		CRichEditUI *pRichEdit = static_cast<CRichEditUI*>(m_PaintManager.FindControl(_T("weiboContent")));
		if (pRichEdit)
		{
			CDuiString strText = pRichEdit->GetText();
			if (strText.GetLength() == 0)
			{
				CLabelUI *plabel = static_cast<CLabelUI*>(m_PaintManager.FindControl(_T("defaultShowText")));
				if (plabel)
				{
					plabel->SetVisible(true);
				}
			}
		}
	}
	else if (pEvent->Type == UIEVENT_MOUSELEAVE)
	{
		CRichEditUI *pRichEdit = static_cast<CRichEditUI*>(m_PaintManager.FindControl(_T("weiboContent")));
		if (pRichEdit)
		{
			if (!pRichEdit->IsFocused())
			{
				CHorizontalLayoutUI *pWeiboCotentContainer = static_cast<CHorizontalLayoutUI*>(m_PaintManager.FindControl(_T("weiboContentContainer")));
				if (pWeiboCotentContainer)
				{
					pWeiboCotentContainer->SetBorderColor(RGB(204,204,204));
				}
			}
		}
	}
	else if (pEvent->Type == UIEVENT_MOUSEENTER)
	{
		CRichEditUI *pRichEdit = static_cast<CRichEditUI*>(m_PaintManager.FindControl(_T("weiboContent")));
		if (pRichEdit)
		{
			if (!pRichEdit->IsFocused())
			{
				CHorizontalLayoutUI *pWeiboCotentContainer = static_cast<CHorizontalLayoutUI*>(m_PaintManager.FindControl(_T("weiboContentContainer")));
				if (pWeiboCotentContainer)
				{
					pWeiboCotentContainer->SetBorderColor(RGB(0,0,255));
				}
			}
		}
	}

	return true;
}
Example #8
0
void ChatDialog::Notify(TNotifyUI& msg)
{
	if (_tcsicmp(msg.sType, _T("windowinit")) == 0)
	{
		OnPrepare(msg);
	}
	else if (_tcsicmp(msg.sType, _T("killfocus")) == 0)
	{
	}
	else if (_tcsicmp(msg.sType, _T("click")) == 0)
	{
		if (_tcsicmp(msg.pSender->GetName(), kCloseButtonControlName) == 0)
		{
			OnExit(msg);
		}
		else if (_tcsicmp(msg.pSender->GetName(), kMinButtonControlName) == 0)
		{

			SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);

		}
		else if (_tcsicmp(msg.pSender->GetName(), kMaxButtonControlName) == 0)
		{

			SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);

		}
		else if (_tcsicmp(msg.pSender->GetName(), kRestoreButtonControlName) == 0)
		{

			SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);

		}
		else if (_tcsicmp(msg.pSender->GetName(), kFontButtonControlName) == 0)
		{
			CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName));
			if (pFontbar != NULL)
				pFontbar->SetVisible(!pFontbar->IsVisible());
		}
		else if (_tcsicmp(msg.pSender->GetName(), kEmotionButtonControlName) == 0)
		{
			POINT pt = {0};
			CDuiRect rcEmotionBtn = msg.pSender->GetPos();
			CDuiRect rcWindow;
			GetWindowRect(m_hWnd, &rcWindow);

			pt.y = rcWindow.top + rcEmotionBtn.top;
			pt.x = rcWindow.left + rcEmotionBtn.left;
			//emotion_list_window_.SelectEmotion(pt);
			new CEmotion(this,pt);
		}
		else if (_tcsicmp(msg.pSender->GetName(), kSendButtonControlName) == 0)
        {
			CRichEditUI* pRichEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kInputRichEditControlName));
			CRichEditUI* pViewEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kViewRichEditControlName));
			if( pRichEdit == NULL ) return;
			pRichEdit->SetFocus();
			CDuiString sText = pRichEdit->GetTextRange(0, pRichEdit->GetTextLength());
			//CDuiString sText=pRichEdit->GetEditGifStr();
		    if( sText.IsEmpty() ) 
				return;

			int textlen = sText.GetLength();

			if (textlen > 512)
			{  
				pViewEdit->SetTextColor(RGB(255,0,0));
				pViewEdit->SetText(_T("错误!发送数据的长度不能超过512字节。")); 
			}
			else
			{
				int imNum = friend_.id;
				TCHAR sendmesg[513] = {0};


				_stprintf_s(sendmesg,512,_T("%s"),sText.GetData());
				int len = strlen(sendmesg);

				if (len !=textlen)
				{
					pViewEdit->SetTextColor(RGB(255,0,0));
					pViewEdit->SetText(_T("警告!发送数据的长度和计算的不同。")); 
				}
				frame_wnd_->m_pTcpCommunication->SendMsg(MSG_TYPE_FRIEND,imNum,sendmesg,textlen);
				//显示在
				SendMsg(g_myself_info.nick_name,sText);
				pRichEdit->SetText(_T(""));
                //test
				//CDuiString strbmp;
				//strbmp.Format("c:\\1.gif");
				//pRichEdit->InsertGif(strbmp);
			}

		}
	}
    else if( _tcsicmp(msg.sType, _T("return")) == 0 ) 
    {
        if (_tcsicmp(msg.pSender->GetName(), kInputRichEditControlName) == 0)
        {
			CRichEditUI* pRichEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kInputRichEditControlName));
			CRichEditUI* pViewEdit = static_cast<CRichEditUI*>(paint_manager_.FindControl(kViewRichEditControlName));
			if( pRichEdit == NULL ) return;
			pRichEdit->SetFocus();
			CDuiString sText = pRichEdit->GetTextRange(0, pRichEdit->GetTextLength());
			if( sText.IsEmpty() ) 
				return;

			int textlen = sText.GetLength();

			if (textlen > 512)
			{  
				pViewEdit->SetTextColor(RGB(255,0,0));
				pViewEdit->SetText(_T("错误!发送数据的长度不能超过512字节。")); 
			}
			else
			{
				int imNum = friend_.id;
				TCHAR sendmesg[513] = {0};
                 
				
				_stprintf_s(sendmesg,512,_T("%s"),sText.GetData());
                int len = strlen(sendmesg);

				if (len !=textlen)
				{
					pViewEdit->SetTextColor(RGB(255,0,0));
					pViewEdit->SetText(_T("警告!发送数据的长度和计算的不同。")); 
				}
				frame_wnd_->m_pTcpCommunication->SendMsg(MSG_TYPE_FRIEND,imNum,sendmesg,textlen);
				//显示在
				SendMsg(g_myself_info.nick_name,sText);
				pRichEdit->SetText(_T(""));
			}
        }
    }
	else if (_tcsicmp(msg.sType, _T("timer")) == 0)
	{
		return OnTimer(msg);
	}
	else if (_tcsicmp(msg.sType, _T("selectchanged")) == 0)
	{
		if (_tcsicmp(msg.pSender->GetName(), kColorButtonControlName) == 0)
		{
			CContainerUI* pFontbar = static_cast<CContainerUI*>(paint_manager_.FindControl(kFontbarControlName));
			if (pFontbar != NULL)
			{
				POINT pt = {0};
				CDuiRect rcFontbar = pFontbar->GetPos();
				CDuiRect rcColorBtn = msg.pSender->GetPos();
				CDuiRect rcWindow;
				GetWindowRect(m_hWnd, &rcWindow);

				pt.y = rcWindow.top + rcFontbar.top;
				pt.x = rcWindow.left + rcColorBtn.left + static_cast<LONG>(rcColorBtn.right - rcColorBtn.left / 2);
				
			     new CColorPicker((ChatDialog*)this, pt);
			
			}
		}
		else if (_tcsicmp(msg.pSender->GetName(), kBoldButtonControlName) == 0)
		{
			COptionUI* bold_button = static_cast<COptionUI*>(msg.pSender);
			if (bold_button != NULL)
			{
				bold_ = bold_button->IsSelected();
				FontStyleChanged();
			}
		}
		else if (_tcsicmp(msg.pSender->GetName(), kItalicButtonControlName) == 0)
		{
			COptionUI* italic_button = static_cast<COptionUI*>(msg.pSender);
			if (italic_button != NULL)
			{
				italic_ = italic_button->IsSelected();
				FontStyleChanged();
			}
		}
		else if (_tcsicmp(msg.pSender->GetName(), KUnderlineButtonControlName) == 0)
		{
			COptionUI* underline_button = static_cast<COptionUI*>(msg.pSender);
			if (underline_button != NULL)
			{
				underline_ = underline_button->IsSelected();
				FontStyleChanged();
			}
		}
	}
	else if (_tcsicmp(msg.sType, _T("itemselect")) == 0)
	{
		if (_tcsicmp(msg.pSender->GetName(), kFontTypeControlName) == 0)
		{
			CComboUI* font_type = static_cast<CComboUI*>(msg.pSender);
			if (font_type != NULL)
			{
				font_face_name_ = font_type->GetText();
				FontStyleChanged();
			}
		}
		else if (_tcsicmp(msg.pSender->GetName(), kFontSizeControlName) == 0)
		{
			CComboUI* font_size = static_cast<CComboUI*>(msg.pSender);
			if (font_size != NULL)
			{
				font_size_ = _ttoi(font_size->GetText());
				FontStyleChanged();
			}
		}
	}
}
Example #9
0
void CFileUtil::SplitFileName(CDuiString fileName,CDuiString &name,CDuiString &exName)
{
	name = fileName.Left(fileName.Find(L"."));
	exName = fileName.Right(fileName.GetLength()-name.GetLength()-1);
}
Example #10
0
BOOL CFileUtil::OpenFile(LPCWSTR lpstrFilter, HWND hwndOwner, vector<CDuiString> &fileNames, bool IsMulti)
{
	DWORD dwFlag = IsMulti ? OFN_ALLOWMULTISELECT : 0;
	TCHAR szFileName[MAX_PATH * 101 + 1] = _T("");

	OPENFILENAME openfilename = {0};

	ZeroMemory(&openfilename, sizeof(OPENFILENAME));

	CDuiString s_title;

	openfilename.lStructSize       = sizeof(OPENFILENAME);
	openfilename.hwndOwner         = hwndOwner;
	openfilename.hInstance         = NULL;
	openfilename.lpstrFilter       = lpstrFilter;
	openfilename.lpstrCustomFilter = NULL;
	openfilename.nMaxCustFilter    = 0L;
	openfilename.nFilterIndex      = 1L;
	openfilename.lpstrFile         = szFileName;
	openfilename.nMaxFile          = MAX_PATH * 101 + 1;
	openfilename.lpstrFileTitle    = NULL;
	openfilename.nMaxFileTitle     = 0;
	openfilename.lpstrInitialDir   = NULL ;
	openfilename.lpstrTitle        = s_title;
	openfilename.nFileOffset       = 0;
	openfilename.nFileExtension    = 0;
	openfilename.lpstrDefExt       = _T("*.*");
	openfilename.lCustData         = 0;
	openfilename.Flags             = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_READONLY | OFN_EXPLORER | dwFlag;
	
	// 弹出打开文件的对话框
	CDuiString str;

	if (::GetOpenFileName(&openfilename))
	{
		LPTSTR p = szFileName;
		CDuiString TempPath;
		if (*p != NULL)
		{
			TempPath =  p;
			p    += TempPath.GetLength() + 1;
		}

		if (*p == NULL)
		{
		//	TempPath = TempPath.Left(TempPath.ReverseFind(L'\\'));
			fileNames.push_back(TempPath);
		}


		while (*p != NULL)
		{
			CDuiString str = p;

			p += str.GetLength() + 1;

			fileNames.push_back(TempPath + _T("\\") + str);
		}

		return TRUE;
	}
	else
	{
		return FALSE;
	}

}
Example #11
0
BOOL CFileUtil::BrowseAllFile(CDuiString path,LPCWSTR lpstrFilter,vector<FILE_STRUCT> &files)
{
	vector<CDuiString> filters;
	CDuiString filter;
	if (lpstrFilter!=NULL)
	{
		LPCWSTR p = lpstrFilter;
		while (*p!=NULL)
		{
			filter = p;
			p+=filter.GetLength()+1;
			filters.push_back(filter);
		}

	}

	FILE_STRUCT file;
	WIN32_FIND_DATA fd;  
	HANDLE fHandle=FindFirstFile(path,&fd);
	if (fHandle == INVALID_HANDLE_VALUE)
	{
		return FALSE;
	}

	file.fileName = fd.cFileName;
	file.size = fd.nFileSizeLow-fd.nFileSizeHigh;
	file.name = file.fileName.Left(file.fileName.Find(L"."));
	file.exName = file.fileName.Right(file.fileName.GetLength()-file.name.GetLength()-1);

	if (lpstrFilter!=NULL)
	{
		for (UINT i =0;i<filters.size();i++)
		{
			if (filters[i] == file.exName)
			{
				files.push_back(file);
			}
		}

	}else
	{
		files.push_back(file);
	}


	if(fHandle!=INVALID_HANDLE_VALUE)  
	{  
		while(FindNextFile(fHandle,&fd))  
		{  
			file.fileName = fd.cFileName;
			file.size = fd.nFileSizeLow-fd.nFileSizeHigh;
			file.name = file.fileName.Left(file.fileName.Find(L"."));
			file.exName = file.fileName.Right(file.fileName.GetLength()-file.name.GetLength()-1);
			if (lpstrFilter!=NULL)
			{
				for (UINT i =0;i<filters.size();i++)
				{
					if (filters[i] == file.exName)
					{
						files.push_back(file);
					}
				}

			}else
			{
				files.push_back(file);
			}
		}  
	}  

	return TRUE;
}