// SelMsgContent3.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "SelMsgContent3.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // SelMsgContent3 dialog SelMsgContent3::SelMsgContent3(CWnd* pParent /*=NULL*/) : CDialog(SelMsgContent3::IDD, pParent) { //{{AFX_DATA_INIT(SelMsgContent3) m_check1 = FALSE; m_check2 = FALSE; m_name = _T(""); m_content1 = _T(""); m_content2 = _T(""); m_point = _T(""); //}}AFX_DATA_INIT } void SelMsgContent3::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(SelMsgContent3) DDX_Control(pDX, IDC_EDIT3, m_editnum1); DDX_Control(pDX, IDC_LIST1, m_List1); DDX_Check(pDX, IDC_CHECK1, m_check1); DDX_Check(pDX, IDC_CHECK2, m_check2); DDX_Text(pDX, IDC_EDIT2, m_name); DDX_Text(pDX, IDC_EDIT1, m_content1); DDX_Text(pDX, IDC_EDIT8, m_content2); DDX_Text(pDX, IDC_EDIT3, m_point); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(SelMsgContent3, CDialog) //{{AFX_MSG_MAP(SelMsgContent3) ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1) ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1) ON_EN_CHANGE(IDC_EDIT8, OnChangeEdit8) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // SelMsgContent3 message handlers int __cdecl CompareByLabel6( const void *elem1, const void *elem2) { CStringArray *p1 = (CStringArray*)elem1; CStringArray *p2 = (CStringArray*)elem2; return atoi( p1->ElementAt (5))>atoi(p2->ElementAt (5) ) ; } BOOL SelMsgContent3::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here g_sendhead.bsql=0; g_sendhead.code[0]=170; g_sendhead.tabcount=1; g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return false; DataToArray(&m_List1array); qsort( static_cast(&m_List1array[0]), m_List1array.GetSize (), sizeof(m_List1array[0]), CompareByLabel6 ); for(int i=0; iProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; MessageBox("保存成功"); m_List1.AddString (m_name); int size=m_List1array.GetSize (); m_List1array.SetSize(size+1, 1); m_List1array.ElementAt (size).RemoveAll (); m_List1array.ElementAt (size).Add (m_name); m_List1array.ElementAt (size).Add (m_content1); m_List1array.ElementAt (size).Add (m_content2); m_List1array.ElementAt (size).Add (check1); m_List1array.ElementAt (size).Add (check2); m_List1array.ElementAt (size).Add (m_point); GetDlgItem(IDC_BUTTON2)->EnableWindow(0); } void SelMsgContent3::OnSelchangeList1() { // TODO: Add your control notification handler code here int pos=m_List1.GetCurSel (); if(pos==-1) { m_oldname.Empty (); GetDlgItem(IDC_BUTTON2)->EnableWindow(0); return; } m_name=m_List1array.ElementAt (pos).ElementAt (0); m_content1=m_List1array.ElementAt (pos).ElementAt (1); m_content2=m_List1array.ElementAt (pos).ElementAt (2); CString check1,check2; check1=m_List1array.ElementAt (pos).ElementAt (3); check2=m_List1array.ElementAt (pos).ElementAt (4); m_point=m_List1array.ElementAt (pos).ElementAt (5); m_check1=atoi(check1); m_check2=atoi(check2); m_oldname=m_name; GetDlgItem(IDC_BUTTON2)->EnableWindow(1); // if(m_content1.IsEmpty())m_content1="xxx先生/女士"; // if(m_content2.IsEmpty())m_content2="xxx先生/女士"; UpdateData(false); } void SelMsgContent3::OnButton1() { // TODO: Add your control notification handler code here int pos=m_List1.GetCurSel (); if(pos==-1)return; if(AfxMessageBox("删除后将无法恢复,是否继续?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return; m_name=m_List1array.ElementAt (pos).ElementAt (0); m_content1=m_List1array.ElementAt (pos).ElementAt (1); CString sql="delete from msgtemp2 where name='"+m_name+"'"; g_sendhead.bsql=1; g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; m_List1.DeleteString (pos); m_List1array.RemoveAt(pos); GetDlgItem(IDC_BUTTON2)->EnableWindow(0); } void SelMsgContent3::OnButton2() { // TODO: Add your control notification handler code here UpdateData(); if(m_oldname.IsEmpty ())return; if(m_name.IsEmpty ())return; if(atoi(m_point)<1)return; /* if(m_content1.Find ("xxx先生/女士")==-1) { m_content1="xxx先生/女士"+m_content1; AfxMessageBox("祝福语不合规范!"); UpdateData(false); return; } if(m_content2.Find ("xxx先生/女士")==-1) { m_content2="xxx先生/女士"+m_content2; AfxMessageBox("祝福语不合规范!"); UpdateData(false); return; }*/ int i = 0; int oldpos=-1; for( i=0; iProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; MessageBox("保存成功"); m_List1array.ElementAt (oldpos).SetAt (0, m_name); m_List1array.ElementAt (oldpos).SetAt (1, m_content1); m_List1array.ElementAt (oldpos).SetAt (2, m_content2); m_List1array.ElementAt (oldpos).SetAt (3, check1); m_List1array.ElementAt (oldpos).SetAt (4, check2); m_List1array.ElementAt (oldpos).SetAt (5, m_point); m_List1.ResetContent (); for( i=0; iEnableWindow(0); } void SelMsgContent3::OnChangeEdit1() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. UpdateData(); /* if(m_content1.Find ("xxx先生/女士")==-1) { m_content1="xxx先生/女士"+m_content1; UpdateData(false); return; }*/ m_content1.Replace ("'", "'"); m_content1.Replace ("(", "("); m_content1.Replace (")", ")"); UpdateData(false); CString str; int count=0; int leng=GetLengthEx(m_content1)-3; count+=(leng/MSG_LENGTH); if(leng%MSG_LENGTH) count+=1; str.Format ("%d字/条,现%d字,共%d条)", MSG_LENGTH,leng,count); GetDlgItem(IDC_STATIC1)->SetWindowText(str); // TODO: Add your control notification handler code here } void SelMsgContent3::OnChangeEdit8() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialog::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. UpdateData(); /* if(m_content2.Find ("xxx先生/女士")==-1) { m_content2="xxx先生/女士"+m_content2; UpdateData(false); return; }*/ m_content2.Replace ("'", "'"); m_content2.Replace ("(", "("); m_content2.Replace (")", ")"); UpdateData(false); CString str; int count=0; int leng=GetLengthEx(m_content2)-3; count+=(leng/MSG_LENGTH); if(leng%MSG_LENGTH) count+=1; str.Format ("%d字/条,现%d字,共%d条)", MSG_LENGTH, leng,count); GetDlgItem(IDC_STATIC2)->SetWindowText(str); // TODO: Add your control notification handler code here } //没有此域名的记录