// MissCall.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "MissCall.h" #include "MyMdi.H" #include "ModifyDinDan.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //#pragma comment(lib, "Shlwapi.lib") ///////////////////////////////////////////////////////////////////////////// // MissCall IMPLEMENT_DYNCREATE(MissCall, MyFormView) MissCall::MissCall() : MyFormView(MissCall::IDD) { //{{AFX_DATA_INIT(MissCall) m_filter = _T(""); //}}AFX_DATA_INIT } MissCall::~MissCall() { } void MissCall::DoDataExchange(CDataExchange* pDX) { MyFormView::DoDataExchange(pDX); //{{AFX_DATA_MAP(MissCall) DDX_Control(pDX, IDC_COMBO1, m_combo1); DDX_Control(pDX, IDC_LIST2, m_List1); DDX_Control(pDX, IDC_STATIC1, m_static1); DDX_CBString(pDX, IDC_COMBO1, m_filter); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(MissCall, MyFormView) //{{AFX_MSG_MAP(MissCall) ON_BN_CLICKED(IDC_BUTclose, OnBUTclose) ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1) ON_WM_TIMER() ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2) ON_BN_CLICKED(IDC_BUTdel, OnBUTdel) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // MissCall diagnostics #ifdef _DEBUG void MissCall::AssertValid() const { MyFormView::AssertValid(); } void MissCall::Dump(CDumpContext& dc) const { MyFormView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // MissCall message handlers void MissCall::OnInitialUpdate() { MyFormView::OnInitialUpdate(); // TODO: Add your specialized code here and/or call the base class CMyMdi Mdi; Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this); // Here we create the outbar control using the splitter as its parent // and setting its id to the first pane. CRect rc2; GetWindowRect(rc2); ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE); EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0); m_static1.SetFont(&g_titlefont); m_List1.SetHeadings("姓名,160;电话号码,160;来电时间,160;类别,160"); m_List1.LoadColumnInfo(159); g_sendhead.bsql = 0; g_sendhead.code[0] = 117; g_sendhead.tabcount = 1; g_pMainWnd->ProcessChatMessageRequest2(1); if (g_bSendOK == 0)return; DataToArray(&m_List1array); FillGrid(); m_combo1.GetWindowRect(rc2); ScreenToClient(rc2); rc2.bottom += 200; m_combo1.MoveWindow(rc2); GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2); SetComboHei(&m_combo1, rc2.Height()); } void MissCall::FillGrid(BOOL bStatus) { m_List1.DeleteAllItems2(); int ii = 0; m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1); int count = 0; if (m_filter.IsEmpty()) { for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++) { m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii)); } } else { for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++) { if (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \ m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1) { m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii)); } } } m_List1.m_arLabels.SetSize(count, 1); ii = count; m_List1.m_LabelCount = ii; m_List1.SetItemCountEx(ii); } void MissCall::OnBUTclose() { // TODO: Add your control notification handler code here GetParent()->SendMessage(WM_CLOSE); } void MissCall::OnSelchangeCombo1() { // TODO: Add your control notification handler code here SetTimer(1, 100, NULL); } void MissCall::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default KillTimer(nIDEvent); OnButton1(); } BOOL MissCall::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class try { if (pMsg->message == WM_KEYDOWN) { switch (pMsg->wParam) { case VK_RETURN: OnButton1(); return 1; case 0x43: // copy if ((GetKeyState(VK_CONTROL) & 0x80)) { GetFocus()->SendMessage(WM_COPY); return TRUE; } break; case 0x56: //Ctrl + V: if ((GetKeyState(VK_CONTROL) & 0x80)) { GetFocus()->SendMessage(WM_PASTE); return TRUE; } break; case 0x58: // cut if ((GetKeyState(VK_CONTROL) & 0x80)) { GetFocus()->SendMessage(WM_CUT); return TRUE; } break; case 0x5A: //undo case 0x59: //redo if ((GetKeyState(VK_CONTROL) & 0x80)) { GetFocus()->SendMessage(WM_UNDO); return TRUE; } break; } } return MyFormView::PreTranslateMessage(pMsg); } catch (...) { } return TRUE; } void MissCall::OnButton1() { // TODO: Add your control notification handler code here UpdateData(); m_filter.TrimLeft(); m_filter.TrimRight(); FillGrid(); } void MissCall::OnButton2() { // TODO: Add your control notification handler code here UpdateData(); m_filter.TrimLeft(); m_filter.TrimRight(); FillGrid(1); } void MissCall::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; // TODO: Add your control notification handler code here POSITION pos; pos = m_List1.GetFirstSelectedItemPosition(); if (pos == NULL) { return; } int iItem = m_List1.GetNextSelectedItem(pos); CString waiter5 = m_List1.GetItemText(iItem, 8); if (waiter5.IsEmpty() && IsHasRights2new(5) || IsHasRights2new(49)) { GetDlgItem(IDC_BUTimportphoto)->EnableWindow(1); } else if (waiter5 == g_user.name && IsHasRights2new(5)) { GetDlgItem(IDC_BUTimportphoto)->EnableWindow(1); } else GetDlgItem(IDC_BUTimportphoto)->EnableWindow(0); *pResult = 0; } BOOL MissCall::CheckOK(CString name) { if (name.GetLength() > 4)return 0; for (int i = 0; i < name.GetLength(); i++) { if (name.GetAt(i) < '0' || name.GetAt(i) > '9')return 0; } return 1; } void MissCall::OnBUTdel() { // TODO: Add your control notification handler code here if (IsHasRights2new(49) == 0)return; // TODO: Add your control notification handler code here POSITION pos; pos = m_List1.GetFirstSelectedItemPosition(); if (pos == NULL) { AfxMessageBox("请先选中您要删除的记录!", MB_ICONINFORMATION); return; } if (AfxMessageBox("删除后将无法恢复,是否继续?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return; int iItem = m_List1.GetNextSelectedItem(pos); CString datetime = m_List1.GetItemText(iItem, 2); CString sql; sql.Format("delete from misscallrecord where datetime='%s' ", datetime); g_sendhead.bsql = 1; g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return; g_sendhead.bsql = 0; g_sendhead.code[0] = 117; g_sendhead.tabcount = 1; g_pMainWnd->ProcessChatMessageRequest2(1); if (g_bSendOK == 0)return; DataToArray(&m_List1array); FillGrid(); }