// AppDataSP3DTdConListView.cpp : implementation file // #include "stdafx.h" #include "geomative.h" #include "AppDataSP3DTdConListView.h" #include "delelectrode.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CAppDataSP3DTdConListView 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; IMPLEMENT_DYNCREATE(CAppDataSP3DTdConListView, CListView) CAppDataSP3DTdConListView::CAppDataSP3DTdConListView() { m_pMngFrm = NULL; } CAppDataSP3DTdConListView::~CAppDataSP3DTdConListView() { } BEGIN_MESSAGE_MAP(CAppDataSP3DTdConListView, CListView) //{{AFX_MSG_MAP(CAppDataSP3DTdConListView) ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick) 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() ///////////////////////////////////////////////////////////////////////////// // CAppDataSP3DTdConListView drawing void CAppDataSP3DTdConListView::OnDraw(CDC* pDC) { CDocument* pDoc = GetDocument(); // TODO: add draw code here } ///////////////////////////////////////////////////////////////////////////// // CAppDataSP3DTdConListView diagnostics #ifdef _DEBUG void CAppDataSP3DTdConListView::AssertValid() const { CListView::AssertValid(); } void CAppDataSP3DTdConListView::Dump(CDumpContext& dc) const { CListView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CAppDataSP3DTdConListView message handlers BOOL CAppDataSP3DTdConListView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Add your specialized code here and/or call the base class cs.style &= ~LVS_TYPEMASK; cs.style |= LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS; return CListView::PreCreateWindow(cs); } void CAppDataSP3DTdConListView::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 CAppDataSP3DTdConListView::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); 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_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); } void CAppDataSP3DTdConListView::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 CAppDataSP3DTdConListView::OnOpDataRemove() { // TODO: Add your command handler code here POSITION pos = this->GetListCtrl().GetFirstSelectedItemPosition(); int iItemIndex = this->GetListCtrl().GetNextSelectedItem(pos); if (iItemIndex != -1) { DWORD dwTSN = this->GetListCtrl().GetItemData(iItemIndex); ::SendMessage(m_pMngFrm->m_hWnd, WM_REMOVE_3D_DATA, (WPARAM)dwTSN, (LPARAM)VAL_ZERO); } else { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("请先选择数据")); else MessageBoxEx(NULL, _T("Please select an item"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); } } void CAppDataSP3DTdConListView::OnOpDeleteElectrode() { CDelElectrode DeleteElecDial; STDelElectInfo stDelElecInfo; if (IDOK == DeleteElecDial.DoModal()) { DeleteElecDial.GetElectrodeIDInfo(stDelElecInfo); if (!stDelElecInfo.vtElectID.empty()) { ::SendMessage(m_pMngFrm->m_hWnd, WM_DELETE_3D_ELECTRODE, (WPARAM)VAL_ZERO, (LPARAM)(&(stDelElecInfo.vtElectID))); Sleep(100); ::SendMessage(m_pMngFrm->m_hWnd, WM_REFRESH_CONLIST, (WPARAM)VAL_ZERO, (LPARAM)VAL_ZERO); } } } void CAppDataSP3DTdConListView::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 CAppDataSP3DTdConListView::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); }