void CvIpmLeft::OnSelchanging(NMHDR* pNMHDR, LRESULT* pResult) { CTreeCtrl& tree = GetTreeCtrl(); CdIpmDoc* pDoc = (CdIpmDoc *)GetDocument(); ASSERT(pDoc); *pResult = 0; // default to allow selchange try { // Manage "update all after load on first action" if (!pDoc) return; if (pDoc->GetPTreeGD()->CurrentlyLoading()) return; if (pDoc->GetLockDisplayRightPane()) return; if (pDoc->ManageMonSpecialState() || m_bProhibitActionOnTreeCtrl) { *pResult = 1; return; } NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; HTREEITEM hItem = pNMTreeView->itemNew.hItem; CTreeItem *pItem; pItem = (CTreeItem *)tree.GetItemData(hItem); if (pItem) { if (!pItem->CompleteStruct()) { //"Structure Not Completed" AfxMessageBox(IDS_E_STRUCTURE, MB_OK | MB_ICONEXCLAMATION); *pResult = 1; // prevent selchange return; } // Manage old item replicator dbevents HTREEITEM hOldItem = pNMTreeView->itemOld.hItem; if (hOldItem) { CTreeItem *pOldItem; pOldItem = (CTreeItem *)tree.GetItemData(hOldItem); ASSERT (pOldItem); if (pOldItem) { // Cannot rely on "if (!pOldItem->ItemDisplaysNoPage())" // because replication can have been installed/uninstalled since then // ---> must terminate or not according to m_ReplMonHandle value if (pOldItem->HasReplicMonitor()) { pDoc->TerminateReplicator(); } } } // Notify current page on the right that we are about to leave it CfIpmFrame* pFrame = (CfIpmFrame*)GetParentFrame(); ASSERT (pFrame); if (pFrame) { if (pFrame->IsAllViewCreated()) { CuDlgIpmTabCtrl* pTabDlg = (CuDlgIpmTabCtrl*)pFrame->GetTabDialog(); if (pTabDlg) pTabDlg->NotifyPageSelChanging(); } } } } catch (...) { AfxMessageBox (IDS_E_CONSTRUCT_PROPERTY); } }
void CvIpmLeft::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult) { IPMUPDATEPARAMS ups; NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; CdIpmDoc* pDoc = (CdIpmDoc *)GetDocument(); try { ASSERT(pDoc); if (!pDoc) return; if (pDoc->GetLockDisplayRightPane()) return; CfIpmFrame* pFrame = (CfIpmFrame*)GetParentFrame(); ASSERT (pFrame); if (!pFrame) return; if (!pFrame->IsAllViewCreated()) return; CuDlgIpmTabCtrl* pTabDlg = (CuDlgIpmTabCtrl*)pFrame->GetTabDialog(); if (!pTabDlg) return; CWaitCursor doWaitCursor ; // // Notify the container of sel change: CIpmCtrl* pIpmCtrl = (CIpmCtrl*)pFrame->GetParent(); if (pIpmCtrl) pIpmCtrl->ContainerNotifySelChange(); memset (&ups, 0, sizeof (ups)); CTreeCtrl& treeCtrl = GetTreeCtrl(); CTreeItem* pItem = (CTreeItem*)treeCtrl.GetItemData (pNMTreeView->itemNew.hItem); if (pItem->IsNoItem() || pItem->IsErrorItem()) { pTabDlg->DisplayPage (NULL); *pResult = 0; return; } if (pItem->ItemDisplaysNoPage()) { CString caption = pItem->ItemNoPageCaption(); pTabDlg->DisplayPage (NULL, caption); *pResult = 0; return; } if (pItem->HasReplicMonitor()) { pDoc->InitializeReplicator(pItem->GetDBName()); } int nImage = -1, nSelectedImage = -1; CImageList* pImageList = treeCtrl.GetImageList (TVSIL_NORMAL); HICON hIcon = NULL; int nImageCount = pImageList? pImageList->GetImageCount(): 0; if (pImageList && treeCtrl.GetItemImage(pNMTreeView->itemNew.hItem, nImage, nSelectedImage)) { if (nImage < nImageCount) hIcon = pImageList->ExtractIcon(nImage); } CuPageInformation* pPageInfo = pItem->GetPageInformation(); CString strItem = pItem->GetRightPaneTitle(); pItem->UpdateDataWhenSelChange(); // Has an effect only if the class has specialied the method. ups.nType = pItem->GetType(); ups.pStruct = pItem->GetPTreeItemData()? pItem->GetPTreeItemData()->GetDataPtr(): NULL; ups.pSFilter= pDoc->GetPTreeGD()->GetPSFilter(); pPageInfo->SetUpdateParam (&ups); pPageInfo->SetTitle ((LPCTSTR)strItem, pItem, pDoc); pPageInfo->SetImage (hIcon); pTabDlg->DisplayPage (pPageInfo); } catch(CMemoryException* e) { theApp.OutOfMemoryMessage(); e->Delete(); } catch(CResourceException* e) { AfxMessageBox (IDS_E_LOAD_DLG); e->Delete(); } catch(...) { AfxMessageBox (IDS_E_CONSTRUCT_PROPERTY); } *pResult = 0; }