// appdataipsp2dtdconlistview.cpp : implementation file // #include "stdafx.h" #include "geomative.h" #include "appdataipsp2dtdconlistview.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; ///////////////////////////////////////////////////////////////////////////// // CAppDataIpsp2DTdConListView IMPLEMENT_DYNCREATE(CAppDataIpsp2DTdConListView, CListView) CAppDataIpsp2DTdConListView::CAppDataIpsp2DTdConListView() { m_pMngFrm = NULL; } CAppDataIpsp2DTdConListView::~CAppDataIpsp2DTdConListView() { } BEGIN_MESSAGE_MAP(CAppDataIpsp2DTdConListView, CListView) //{{AFX_MSG_MAP(CAppDataIpsp2DTdConListView) 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() ///////////////////////////////////////////////////////////////////////////// // CAppDataIpsp2DTdConListView drawing void CAppDataIpsp2DTdConListView::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); // TODO: add draw code here } ///////////////////////////////////////////////////////////////////////////// // CAppDataIpsp2DTdConListView diagnostics #ifdef _DEBUG void CAppDataIpsp2DTdConListView::AssertValid() const { CListView::AssertValid(); } void CAppDataIpsp2DTdConListView::Dump(CDumpContext& dc) const { CListView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CAppDataIpsp2DTdConListView message handlers void CAppDataIpsp2DTdConListView::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 CAppDataIpsp2DTdConListView::OnInitialUpdate() { CListView::OnInitialUpdate(); // TODO: Add your specialized code here and/or call the base class CString strColTitle; int iColIndex = (int)VAL_ZERO; GetListCtrl().SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP | LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES|LVS_EX_MULTIWORKAREAS); m_pMngFrm = (CMDIChildWnd*)GetParentFrame(); g_iCurrListColIndex = (int)VAL_ZERO; g_iCurrListColOrder = (int)VAL_ZERO; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_TD2DCON_C1); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 65); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_TD2DCON_C2); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 65); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_TD2DCON_P1); GetListCtrl().InsertColumn(iColIndex, strColTitle, LVCFMT_LEFT, 65); iColIndex++; strColTitle.Empty(); strColTitle.LoadString(IDS_DB_TD2DCON_P2); 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_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 CAppDataIpsp2DTdConListView::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 CAppDataIpsp2DTdConListView::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 CAppDataIpsp2DTdConListView::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 CAppDataIpsp2DTdConListView::OnOpDataRemove() { // TODO: Add your command handler code here 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_2D_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); } } void CAppDataIpsp2DTdConListView::OnOpDeleteElectrode() { CDelElectrode DeleteElecDial; STDelElectInfo stDelElecInfo; if (IDOK == DeleteElecDial.DoModal()) { DeleteElecDial.GetElectrodeIDInfo(stDelElecInfo); if (!stDelElecInfo.vtElectID.empty()) { ::SendMessage(m_pMngFrm->m_hWnd, WM_DELETE_2D_ELECTRODE, (WPARAM)VAL_ZERO, (LPARAM)(&(stDelElecInfo.vtElectID))); Sleep(100); ::SendMessage(m_pMngFrm->m_hWnd, WM_REFRESH_CONLIST, (WPARAM)VAL_ZERO, (LPARAM)VAL_ZERO); } } } void CAppDataIpsp2DTdConListView::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 CAppDataIpsp2DTdConListView::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); }