// navdataview.cpp : implementation file // #include "stdafx.h" #include "geomative.h" #include "navdataview.h" #include "Constant.h" #include "MainFrm.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern CGeoMativeApp theApp; ///////////////////////////////////////////////////////////////////////////// // CNavDataView UINT32 g_ui32PageCount = 0; IMPLEMENT_DYNCREATE(CNavDataView, CFormView) CNavDataView::CNavDataView() : CFormView(CNavDataView::IDD) { //{{AFX_DATA_INIT(CNavDataView) //}}AFX_DATA_INIT } CNavDataView::~CNavDataView() { } void CNavDataView::DoDataExchange(CDataExchange* pDX) { CFormView::DoDataExchange(pDX); //{{AFX_DATA_MAP(CNavDataView) DDX_Control(pDX, IDC_NAV_DATA_TREE, m_dataTree); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CNavDataView, CFormView) //{{AFX_MSG_MAP(CNavDataView) ON_WM_SIZE() ON_NOTIFY(NM_RCLICK, IDC_NAV_DATA_TREE, OnRclickNavDataTree) ON_NOTIFY(TVN_SELCHANGED, IDC_NAV_DATA_TREE, OnSelchangedNavDataTree) ON_NOTIFY(TVN_SELCHANGING, IDC_NAV_DATA_TREE, OnSelchangingNavDataTree) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CNavDataView diagnostics #ifdef _DEBUG void CNavDataView::AssertValid() const { CFormView::AssertValid(); } void CNavDataView::Dump(CDumpContext& dc) const { CFormView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CNavDataView message handlers void CNavDataView::OnInitialUpdate() { CFormView::OnInitialUpdate(); // TODO: Add your specialized code here and/or call the base class InitializeFlatSB(this->m_hWnd); FlatSB_ShowScrollBar(this->m_hWnd, SB_BOTH, FALSE); m_dataTree.ModifyStyle(0, TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS); } void CNavDataView::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); // TODO: Add your message handler code here CTreeCtrl* pNavTree = NULL; pNavTree = (CTreeCtrl*)GetDlgItem(IDC_NAV_DATA_TREE); if ((NULL != pNavTree)) { CRect rect; GetClientRect(&rect); pNavTree->MoveWindow(&rect); } pNavTree = NULL; } void CNavDataView::Schedule() { HTREEITEM hDataItem = NULL; DWORD dwItemHandle = (DWORD)VAL_ZERO; DWORD dwImageState = (DWORD)VAL_ZERO; DWORD dwTempStyle = (DWORD)VAL_ZERO; hDataItem = m_dataTree.GetSelectedItem();//这里没错 // CString sztmp; // sztmp = m_dataTree.GetItemText(hDataItem); if (NULL != hDataItem) { dwItemHandle = m_dataTree.GetItemData(hDataItem); dwImageState = m_dataTree.GetItemState(hDataItem, TVIS_STATEIMAGEMASK); } else { dwTempStyle = PZ_STYLE_PRO; dwTempStyle <<= HANDLE_OFFSET; dwItemHandle |= dwTempStyle; } ::SendMessage(GetParentFrame()->m_hWnd, WM_SCHEDULE, (WPARAM)dwItemHandle, (LPARAM)dwImageState); } void CNavDataView::LoadByPageShedule() { HTREEITEM hDataItem = NULL; DWORD dwItemHandle = (DWORD)VAL_ZERO; DWORD dwImageState = (DWORD)VAL_ZERO; DWORD dwTempStyle = (DWORD)VAL_ZERO; hDataItem = m_dataTree.GetSelectedItem();//这里没错 // CString sztmp; // sztmp = m_dataTree.GetItemText(hDataItem); if (NULL != hDataItem) { dwItemHandle = m_dataTree.GetItemData(hDataItem); dwImageState = m_dataTree.GetItemState(hDataItem, TVIS_STATEIMAGEMASK); } else { dwTempStyle = PZ_STYLE_PRO; dwTempStyle <<= HANDLE_OFFSET; dwItemHandle |= dwTempStyle; } ::SendMessage(GetParentFrame()->m_hWnd, WM_LOAD_BY_PAGE_SCHEDULE, (WPARAM)dwItemHandle, (LPARAM)dwImageState); } void CNavDataView::OnRclickNavDataTree(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here CMainFrame* pMainFrm = NULL; HTREEITEM hHitItem = NULL; UINT uFlags; CPoint treePoint; GetCursorPos(&treePoint); m_dataTree.ScreenToClient(&treePoint); // MapWindowPoints(&m_proTree, &treePoint, 1); hHitItem = m_dataTree.HitTest(treePoint, &uFlags); m_dataTree.SelectItem(hHitItem); m_dataTree.ClientToScreen(&treePoint); // Schedule(); pMainFrm = (CMainFrame*)AfxGetMainWnd(); if (pMainFrm->MDIGetActive()->IsZoomed()) { if ((NULL != hHitItem) && (TVHT_ONITEM & uFlags)) { if (NULL != pMainFrm->GetMenu()->GetSubMenu(2)->GetSubMenu(2)) { pMainFrm->GetMenu()->GetSubMenu(2)->GetSubMenu(2)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, treePoint.x, treePoint.y, GetParentFrame()); } } else if (NULL == hHitItem) { if (NULL != pMainFrm->GetMenu()->GetSubMenu(2)->GetSubMenu(2)) { GetCursorPos(&treePoint); pMainFrm->GetMenu()->GetSubMenu(2)->GetSubMenu(2)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, treePoint.x, treePoint.y, GetParentFrame()); } } } else { if ((NULL != hHitItem) && (TVHT_ONITEM & uFlags)) { if (NULL != pMainFrm->GetMenu()->GetSubMenu(1)->GetSubMenu(2)) { pMainFrm->GetMenu()->GetSubMenu(1)->GetSubMenu(2)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, treePoint.x, treePoint.y, GetParentFrame()); } } else if (NULL == hHitItem) { if (NULL != pMainFrm->GetMenu()->GetSubMenu(1)->GetSubMenu(2)) { GetCursorPos(&treePoint); pMainFrm->GetMenu()->GetSubMenu(1)->GetSubMenu(2)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, treePoint.x, treePoint.y, GetParentFrame()); } } } *pResult = 0; } void CNavDataView::OnSelchangedNavDataTree(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; // TODO: Add your control notification handler code here if (pNMTreeView->itemOld.hItem != pNMTreeView->itemNew.hItem) { //切换 g_ui32PageCount = 0; CString strLog; strLog.Format(_T("zm:初始化g_ui32PageCount=%d\n"), g_ui32PageCount); OutputDebugString(strLog); Schedule(); } *pResult = 0; } void CNavDataView::OnSelchangingNavDataTree(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; // TODO: Add your control notification handler code here if (0x1000 == pNMTreeView->action) { *pResult = 1; } else { *pResult = 0; } } void CNavDataView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) { // TODO: Add your specialized code here and/or call the base class if (TRUE == bActivate) { Schedule(); } CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView); }