www.gusucode.com > VC++三子棋游戏源码(类似五子棋)-源码程序 > VC++三子棋游戏源码(类似五子棋)-源码程序\code\ChatBtmDlg.cpp
//Download by http://www.NewXing.com // ChatBtmDlg.cpp : implementation file // #include "stdafx.h" #include "SanQi.h" #include "ChatBtmDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CChatBtmDlg dialog CChatBtmDlg::CChatBtmDlg(CWnd* pParent /*=NULL*/) : CDialog(CChatBtmDlg::IDD, pParent) { //{{AFX_DATA_INIT(CChatBtmDlg) m_strChatMessage = _T(""); //}}AFX_DATA_INIT } void CChatBtmDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CChatBtmDlg) DDX_Control(pDX, IDC_MESSAGEBOX, m_cmbChatMessage); DDX_CBString(pDX, IDC_MESSAGEBOX, m_strChatMessage); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CChatBtmDlg, CDialog) //{{AFX_MSG_MAP(CChatBtmDlg) ON_BN_CLICKED(IDC_SENDMSG, OnSendMsg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CChatBtmDlg message handlers BOOL CChatBtmDlg::Create(CWnd* pParentWnd) { return CDialog::Create(IDD, pParentWnd); } void CChatBtmDlg::OnOK() { OnSendMsg(); } void CChatBtmDlg::OnCancel() { } void CChatBtmDlg::OnSendMsg() { BOOL bCanSend = GetDlgItem(IDC_SENDMSG)->IsWindowEnabled(); if(!bCanSend) { //GetDlgItem(IDC_SENDMSG)->EnableWindow(TRUE); return; } GetDlgItem(IDC_SENDMSG)->EnableWindow(FALSE); UpdateData(); m_strChatMessage.TrimLeft(" "); m_strChatMessage.TrimRight(" "); int len = m_strChatMessage.GetLength(); if(len > 128) m_strChatMessage = m_strChatMessage.Left(128); char *szMessage = m_strChatMessage.GetBuffer(0); if(len > 0) { HWND hWnd = ::AfxGetMainWnd()->m_hWnd; ::SendMessage(hWnd,WM_SEND_CHATMSG,(WPARAM)szMessage,0); m_strChatMessage.ReleaseBuffer(); BOOL bInsert = TRUE; int count = m_cmbChatMessage.GetCount(); for(int i=0;i<count;i++) { CString strMessage(""); m_cmbChatMessage.GetLBText(i,strMessage); if(strMessage == (CString)szMessage) { bInsert = FALSE; break; } } if(bInsert) { m_cmbChatMessage.InsertString(0,szMessage); } } m_strChatMessage = ""; UpdateData(FALSE); m_cmbChatMessage.SetCurSel(-1); m_cmbChatMessage.SetFocus(); GetDlgItem(IDC_SENDMSG)->EnableWindow(TRUE); }