ChatEdit.cpp
上传用户:zslianheng
上传日期:2013-04-03
资源大小:946k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Visual C++

  1. /***************************************************************************
  2.  *                                                                         *
  3.  *   This program is free software; you can redistribute it and/or modify  *
  4.  *   it under the terms of the GNU General Public License as published by  *
  5.  *   the Free Software Foundation; either version 2 of the License, or     *
  6.  *   (at your option) any later version.                                   *
  7.  *                                                                         *
  8.  *   copyright            : (C) 2002 by Zhang Yong                         *
  9.  *   email                : z-yong163@163.com                              *
  10.  ***************************************************************************/
  11. // ChatEdit.cpp : implementation file
  12. //
  13. #include "stdafx.h"
  14. #include "chat.h"
  15. #include "ChatEdit.h"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. #define MAX_LINES 10
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CChatEdit
  24. CChatEdit::CChatEdit()
  25. {
  26. }
  27. CChatEdit::~CChatEdit()
  28. {
  29. }
  30. BEGIN_MESSAGE_MAP(CChatEdit, CEdit)
  31. //{{AFX_MSG_MAP(CChatEdit)
  32. ON_WM_CHAR()
  33. //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35. /////////////////////////////////////////////////////////////////////////////
  36. // CChatEdit message handlers
  37. void CChatEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
  38. {
  39. if (nChar == VK_RETURN) {
  40. int line = (LineFromChar() + 1) % MAX_LINES;
  41. int start = LineIndex(line);
  42. if (start >= 0) {
  43. int end = LineIndex(line + 1);
  44. if (end > 2)
  45. end -= 2;
  46. SetSel(start, end);
  47. Clear();
  48. return;
  49. }
  50. }
  51. CEdit::OnChar(nChar, nRepCnt, nFlags);
  52. }