www.pudn.com > fanccMSNr.src.rar > SendView.cpp
// SendView.cpp : ±¸Çö ÆÄÀÏÀÔ´Ï´Ù.
//
#include "stdafx.h"
#include "DumbMessenger.h"
#include "ChatFrame.h"
#include "SendView.h"
// CSendView
IMPLEMENT_DYNCREATE(CSendView, CEditView)
CSendView::CSendView()
{
frame=NULL;
}
CSendView::~CSendView()
{
}
BEGIN_MESSAGE_MAP(CSendView, CEditView)
ON_CONTROL_REFLECT(EN_CHANGE, OnEnChange)
ON_WM_CHAR()
END_MESSAGE_MAP()
// CSendView Áø´ÜÀÔ´Ï´Ù.
#ifdef _DEBUG
void CSendView::AssertValid() const
{
CEditView::AssertValid();
}
void CSendView::Dump(CDumpContext& dc) const
{
CEditView::Dump(dc);
}
#endif //_DEBUG
// CSendView ¸Þ½ÃÁö 󸮱âÀÔ´Ï´Ù.
void CSendView::OnEnChange()
{
// ¾Æ¹« Àϵµ ÇÏÁö ¾Ê´Â´Ù.
// CEditView°¡ GetDocument()¸¦ È£ÃâÇØ¼ ¿À·ù¸¦ ³»´Â °ÍÀ» ¸·±â À§ÇÑ ¸Þ½ÃÁö ÈÄÅ·ÀÌ´Ù.
}
void CSendView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if ((nChar != VK_RETURN) || (nRepCnt!=1))
{
CEditView::OnChar(nChar, nRepCnt, nFlags);
return;
}
// ¹®ÀÚ¿ Àü¼Û
else {
// try {
CString strText;
GetEditCtrl().GetWindowText(strText);
const char *userInput=(LPCTSTR)strText;
ASSERT(frame!=NULL);
ASSERT(frame->model!=NULL);
ASSERT(frame->chatView!=NULL);
// ÀÔ·ÂµÈ ¹®ÀÚ¸¦ Àü¼Û
frame->model->sendMessage(userInput);
// ȸ鿡 ¿¡ÄÚ
MessengerModel &messengerModel=frame->model->getMessengerModel();
ASSERT(&messengerModel!=NULL);
string text=messengerModel.getMy().screenName;
text.append("´ÔÀÇ ¸»:\r\n ");
text.append(userInput);
text.append("\r\n");
CEdit &edit=frame->chatView->GetEditCtrl();
int nText = frame->chatView->GetWindowTextLength();
edit.SetSel(nText, nText);
edit.ReplaceSel(text.data());
// ÀÔ·Ââ¿¡¼ »èÁ¦
strText=_T("");
GetEditCtrl().SetWindowText(strText);
// } catch(SocketException e) {
//TODO: handle exception!
// }
}
}