// appdatarspcetdconlistview.cpp : implementation file // #include "stdafx.h" #include "geomative.h" #include "appdatarspcetdconlistview.h" #include "delelectrode.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern int g_iCurrListColIndex; extern int g_iCurrListColOrder; extern int CALLBACK ListStrCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lSortObject); extern int g_iUILanguage; extern UINT32 g_ui32PageCount; ///////////////////////////////////////////////////////////////////////////// // CAppDataRspCETdConListView IMPLEMENT_DYNCREATE(CAppDataRspCETdConListView, CListView) CAppDataRspCETdConListView::CAppDataRspCETdConListView() { } CAppDataRspCETdConListView::~CAppDataRspCETdConListView() { } BEGIN_MESSAGE_MAP(CAppDataRspCETdConListView, CListView) //{{AFX_MSG_MAP(CAppDataRspCETdConListView) ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick) ON_WM_LBUTTONDBLCLK() ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick) ON_COMMAND(IDM_OP_DATA_REMOVE, OnOpDataRemove) ON_COMMAND(IDM_OP_REMOVE_ELECTRODE,OnOpDeleteElectrode) //}}AFX_MSG_MAP ON_WM_VSCROLL() ON_WM_MOUSEWHEEL() END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CAppDataRspCETdConListView drawing void CAppDataRspCETdConListView::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); // TODO: add draw code here } ///////////////////////////////////////////////////////////////////////////// // CAppDataRspCETdConListView diagnostics #ifdef _DEBUG void CAppDataRspCETdConListView::AssertValid() const { CListView::AssertValid(); } void CAppDataRspCETdConListView::Dump(CDumpContext& dc) const { CListView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CAppDataRspCETdConListView message handlers void CAppDataRspCETdConListView::OnInitialUpdate() { CListView::OnInitialUpdate(); // TODO: Add your specialized code here and/or call the base class CString strColTitle; int iColIndex = (int)VAL_ZERO; //加入LVS_EX_MULTIWORKAREAS属性,使得可以同时选择多行 GetListCtrl().SetExtendedStyle(LVS_EX_FULLROWSELECT |LVS_EX_HEADERDRAGDROP | LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES |LVS_EX_MULTIWORKAREAS ); // GetListCtrl().SetExtendedStyle(GetListCtrl().GetExtendedStyle()|); m_pMngFrm = (CMDIChildWnd*)GetParentFrame(); g_iCurrListColIndex = (int)VAL_ZERO; g_iCurrListColOrder = (int)VAL_ZERO; /* strColTitle.Empty(); strColTitle.LoadString(IDS_DB_TD2DCON_TSN); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100); iColIndex++; */ strColTitle.Empty(); strColTitle.LoadString(IDS_DB_SCRIPT_a); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 65); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_SCRIPT_b); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 65); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_SCRIPT_x); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 65); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_SCRIPT_y); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 65); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_TD2DCON_N); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 70); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_TD2DCON_K); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_RIGHT, 100); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_TD2DCON_I); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_RIGHT, 100); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_TD2DCON_V); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_RIGHT, 100); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_TD2DCON_R); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_RIGHT, 100); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_TD2DCON_R0); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_RIGHT, 100); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_TD2DCON_SP); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_RIGHT, 100); // iColIndex++; // strColTitle.Empty(); // strColTitle.LoadString(IDS_DB_TD2DCON_HL); // GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 100); } BOOL CAppDataRspCETdConListView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Add your specialized code here and/or call the base class cs.style &= ~LVS_TYPEMASK; cs.style |= LVS_REPORT | LVS_SHOWSELALWAYS; return CListView::PreCreateWindow(cs); } void CAppDataRspCETdConListView::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; // TODO: Add your control notification handler code here g_iCurrListColIndex = pNMListView->iSubItem; g_iCurrListColOrder = !g_iCurrListColOrder; GetListCtrl().SortItems(ListStrCompare, (LPARAM)&GetListCtrl()); *pResult = 0; } void CAppDataRspCETdConListView::OnLButtonDblClk(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default DWORD dwTSN = (DWORD)VAL_ZERO; int iItemIndex = (DWORD)VAL_ZERO; iItemIndex = this->GetListCtrl().HitTest(point); if ((-1 != iItemIndex) && (MK_LBUTTON == nFlags)) { dwTSN = this->GetListCtrl().GetItemData(iItemIndex); ::SendMessage(m_pMngFrm->m_hWnd, WM_DRAWTPSPLINES, (WPARAM)dwTSN, (LPARAM)VAL_ZERO); } CListView::OnLButtonDblClk(nFlags, point); } void CAppDataRspCETdConListView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here CMenu gnMenu; CMenu* pPopGnMenu = NULL; gnMenu.LoadMenu(IDR_EDIT_DATA); pPopGnMenu = gnMenu.GetSubMenu(0); CPoint point(GetMessagePos()); GetListCtrl().ScreenToClient(&point); int item = GetListCtrl().HitTest(point, NULL); if (item == -1) { return; } DWORD dwTSN = this->GetListCtrl().GetItemData(item); GetListCtrl().ClientToScreen(&point); pPopGnMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); *pResult = 0; } void CAppDataRspCETdConListView::OnOpDataRemove() { // TODO: Add your command handler code here // POSITION pos = this->GetListCtrl().GetFirstSelectedItemPosition(); // int iItemIndex = this->GetListCtrl().GetNextSelectedItem(pos); int nRet = 0; if (LANG_ZHCN == g_iUILanguage) nRet = AfxMessageBox(_T("是否删除?"), MB_YESNO); else nRet = MessageBoxEx(NULL, _T("Remove it?"), STRING_MESSAGEBOXEX_TITLE, MB_YESNO, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); if (IDYES != nRet) return; POSITION pos = NULL; DWORD dwTSN = 0; int iItemIndex = -1; bool bRealDelete = false; while((pos = this->GetListCtrl().GetFirstSelectedItemPosition())) { iItemIndex = this->GetListCtrl().GetNextSelectedItem(pos); if(iItemIndex >= 0 && iItemIndex < this->GetListCtrl().GetItemCount()) { bRealDelete = true; dwTSN = this->GetListCtrl().GetItemData(iItemIndex); ::SendMessage(m_pMngFrm->m_hWnd, WM_REMOVE_1D_DATA, (WPARAM)dwTSN, (LPARAM)1); this->GetListCtrl().DeleteItem(iItemIndex); } } if (bRealDelete) { ::SendMessage(m_pMngFrm->m_hWnd, WM_REFRESH_CONLIST, (WPARAM)VAL_ZERO, (LPARAM)VAL_ZERO); } // if (iItemIndex != -1) // { // DWORD dwTSN = this->GetListCtrl().GetItemData(iItemIndex); // ::SendMessage(m_pMngFrm->m_hWnd, WM_REMOVE_1D_DATA, (WPARAM)dwTSN, (LPARAM)VAL_ZERO); // } // else // { // AfxMessageBox("Please select an item"); // } } void CAppDataRspCETdConListView::OnOpDeleteElectrode() { CDelElectrode DeleteElecDial; STDelElectInfo stDelElecInfo; if (IDOK == DeleteElecDial.DoModal()) { DeleteElecDial.GetElectrodeIDInfo(stDelElecInfo); if (!stDelElecInfo.vtElectID.empty()) { ::SendMessage(m_pMngFrm->m_hWnd, WM_DELETE_1D_ELECTRODE, (WPARAM)VAL_ZERO, (LPARAM)(&(stDelElecInfo.vtElectID))); Sleep(100); ::SendMessage(m_pMngFrm->m_hWnd, WM_REFRESH_CONLIST, (WPARAM)VAL_ZERO, (LPARAM)VAL_ZERO); } } } void CAppDataRspCETdConListView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { // TODO: 在此添加消息处理程序代码和/或调用默认值 g_ui32PageCount++; CString strLog; strLog.Format(_T("zm:OnVScroll Page=%u\n"), g_ui32PageCount); OutputDebugString(strLog); ::SendMessage(m_pMngFrm->m_hWnd, WM_LOADING_2D_DATA, (WPARAM)g_ui32PageCount, (LPARAM)VAL_ZERO); CListView::OnVScroll(nSBCode, nPos, pScrollBar); } BOOL CAppDataRspCETdConListView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { // TODO: 在此添加消息处理程序代码和/或调用默认值 g_ui32PageCount++; CString strLog; strLog.Format(_T("zm:鼠标Page=%u\n"), g_ui32PageCount); OutputDebugString(strLog); ::SendMessage(m_pMngFrm->m_hWnd, WM_LOADING_2D_DATA, (WPARAM)g_ui32PageCount, (LPARAM)VAL_ZERO); return CListView::OnMouseWheel(nFlags, zDelta, pt); }