void CvIpmLeft::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { CdIpmDoc* pDoc = (CdIpmDoc*)GetDocument(); ASSERT (pDoc); if (!pDoc) return; CaIpmProperty& property = pDoc->GetProperty(); BOOL bSetToDefaultPercentage = FALSE; //UKS BOOL bRegularStaticSet = TRUE; int nHint = (int)lHint; switch (nHint) { case 1: // Invoked by CdIpmDoc::Initiate() GetTreeCtrl().SendMessage (WM_SETFONT, (WPARAM)property.GetFont(), MAKELPARAM(TRUE, 0)); if (bSetToDefaultPercentage) { CRect rcClient; CfIpmFrame* pFrame = (CfIpmFrame*)GetParentFrame(); ASSERT (pFrame); CSplitterWnd* pSplit = (CSplitterWnd *)pFrame->GetSplitterWnd(); ASSERT (pSplit); pFrame->GetClientRect (rcClient); pSplit->SetColumnInfo(0, (int) (0.4 * (double)rcClient.Width()), 10); pSplit->RecalcLayout(); } // Create regular static set, if needed if (bRegularStaticSet) { CuTMServerStatic *pItem1 = new CuTMServerStatic (pDoc->GetPTreeGD()); CuTMLockinfoStatic *pItem3 = new CuTMLockinfoStatic (pDoc->GetPTreeGD()); CuTMLoginfoStatic *pItem4 = new CuTMLoginfoStatic (pDoc->GetPTreeGD()); CuTMAllDbStatic *pItem5 = new CuTMAllDbStatic (pDoc->GetPTreeGD()); CuTMActiveUsrStatic *pItem6 = new CuTMActiveUsrStatic(pDoc->GetPTreeGD()); CuTMReplAllDbStatic *pItem7 = new CuTMReplAllDbStatic(pDoc->GetPTreeGD()); HTREEITEM hItem1 = pItem1->CreateTreeLine(); HTREEITEM hItem2 = pItem3->CreateTreeLine(); HTREEITEM hItem3 = pItem4->CreateTreeLine(); HTREEITEM hItem4 = pItem5->CreateTreeLine(); HTREEITEM hItem5 = pItem6->CreateTreeLine(); HTREEITEM hItem6 = pItem7->CreateTreeLine(); ASSERT (hItem1 && hItem2 && hItem3 && hItem4 && hItem5 && hItem6); CTreeCtrl& cTree = GetTreeCtrl(); cTree.SelectItem(hItem1); } break; default: break; } }
void CvIpmLeft::OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult) { CTreeCtrl& tree = GetTreeCtrl(); *pResult = 0; // default to allow expanding CdIpmDoc* pDoc = (CdIpmDoc*)GetDocument(); ASSERT(pDoc); if (!pDoc) return; // Manage "update all after load on first action" if (pDoc->GetPTreeGD()->CurrentlyLoading()) return; if (pDoc->ManageMonSpecialState() || m_bProhibitActionOnTreeCtrl) { *pResult = 1; // do not allow expanding return; } NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; if (pNMTreeView->action == TVE_EXPAND) { HTREEITEM hItem = pNMTreeView->itemNew.hItem; CTreeItem *pItem; pItem = (CTreeItem *)tree.GetItemData(hItem); if (pItem && !pItem->IsAlreadyExpanded()) { if (pItem->CreateSubBranches(hItem)) pItem->SetAlreadyExpanded(TRUE); else *pResult = 1; // prevent expanding } } }
void CvIpmLeft::OnInitialUpdate() { CTreeView::OnInitialUpdate(); CdIpmDoc* pDoc = (CdIpmDoc *)GetDocument(); ASSERT(pDoc); CTreeCtrl &tree = GetTreeCtrl(); pDoc->GetPTreeGD()->SetPTree(&tree); CaIpmProperty& property = pDoc->GetProperty(); tree.SendMessage (WM_SETFONT, (WPARAM)property.GetFont(), MAKELPARAM(TRUE, 0)); if (pDoc->IsLoadedDoc()) { // // Recreate tree lines from serialization data pDoc->GetPTreeGD()->FillTreeFromSerialList(); } }
void CvIpmLeft::OnDestroy() { CdIpmDoc* pDoc = (CdIpmDoc *)GetDocument(); ASSERT(pDoc); // delete itemdata associated with each item pDoc->GetPTreeGD()->FreeAllTreeItemsData(); // standard management CTreeView::OnDestroy(); }
void CvIpmLeft::OnRButtonDown(UINT nFlags, CPoint point) { CTreeCtrl& tree = GetTreeCtrl(); if (m_bProhibitActionOnTreeCtrl) { CTreeView::OnRButtonDown(nFlags, point); return; } HTREEITEM hHit = tree.HitTest (point, &nFlags); if (hHit) tree.SelectItem(hHit); CTreeView::OnRButtonDown(nFlags, point); // popup menu if (hHit) { CdIpmDoc* pDoc = (CdIpmDoc *)GetDocument(); ASSERT(pDoc); if (!pDoc) return; // get menu id according to current menuitem UINT menuId = pDoc->GetPTreeGD()->GetContextMenuId(); if (!menuId) return; // load menu CMenu menu; BOOL bSuccess = menu.LoadMenu (menuId); // Note : DestroyMenu automatic in CMenu destructor ASSERT (bSuccess); if (!bSuccess) return; CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CfIpmFrame* pFrame = (CfIpmFrame*)GetParent()->GetParent(); // 2 levels due to splitter wnd ASSERT (pFrame); CWnd* pWndPopupOwner = pFrame; ClientToScreen(&point); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); } }
BOOL CIpmCtrl::SelectItem(LPCTSTR lpszNode, LPCTSTR lpszServer, LPCTSTR lpszUser, LPCTSTR lpszKey, VARIANT FAR* pArrayItem, short nShowTree) { class CaLockDisplayRightPaneProperty { public: CaLockDisplayRightPaneProperty(CdIpmDoc* pDoc):m_pDoc(pDoc), m_bLock(FALSE){} ~CaLockDisplayRightPaneProperty(){UnLock();} void Lock(){m_pDoc->SetLockDisplayRightPane(TRUE);} void UnLock(){m_pDoc->SetLockDisplayRightPane(FALSE);} protected: BOOL m_bLock; CdIpmDoc* m_pDoc; }; CWaitCursor doWaitCursor ; BOOL bOK = FALSE; try { CdIpmDoc* pDoc = new CdIpmDoc(lpszKey, pArrayItem, (BOOL)nShowTree); if (m_pIpmFrame) { m_pIpmFrame->ShowWindow (SW_HIDE); m_pIpmFrame->DestroyWindow(); m_pIpmFrame = NULL; } CaIpmProperty& property = pDoc->GetProperty(); ConstructPropertySet (property); SFILTER* pFilter = theApp.GetFilter(); SFILTER* pDocFilter = pDoc->GetFilter(); memcpy (pDocFilter, pFilter, sizeof(SFILTER)); CaLockDisplayRightPaneProperty lock(pDoc); if (nShowTree == 1) { // // During the process of expanding tree up to search item, // prohibit the display of the properties of the selected tree item lock.Lock(); } CWnd* pParent = this; CRect r; GetClientRect (r); m_pIpmFrame = new CfIpmFrame(pDoc); m_pIpmFrame->Create ( NULL, NULL, WS_CHILD, r, pParent); if (!m_pIpmFrame) return FALSE; m_pIpmFrame->InitialUpdateFrame(NULL, TRUE); m_pIpmFrame->ShowWindow(SW_SHOW); bOK = pDoc->Initiate(lpszNode, lpszServer, lpszUser, NULL); if (!bOK) return FALSE; CTypedPtrList<CObList, CuIpmTreeFastItem*> listItemPath; bOK = IPM_BuildItemPath (pDoc, listItemPath); if (!bOK) { while (!listItemPath.IsEmpty()) delete listItemPath.RemoveHead(); return FALSE; } ExpandUpToSearchedItem(m_pIpmFrame, listItemPath, TRUE); lock.UnLock(); // // Cleanup: while (!listItemPath.IsEmpty()) delete listItemPath.RemoveHead(); // // Fetch the selected tree item and display the corresponding right pane: IPMUPDATEPARAMS ups; CTreeGlobalData* pGD = pDoc->GetPTreeGD(); ASSERT (pGD); if (!pGD) return FALSE; CTreeCtrl* pTree = pGD->GetPTree(); ASSERT (pTree); if (!pTree) return FALSE; CuDlgIpmTabCtrl* pTabDlg = (CuDlgIpmTabCtrl*)m_pIpmFrame->GetTabDialog(); if (!pTabDlg) return FALSE; HTREEITEM hSelected = pTree->GetSelectedItem(); if (!hSelected) return FALSE; // // Notify the container of sel change: ContainerNotifySelChange(); memset (&ups, 0, sizeof (ups)); CTreeItem* pItem = (CTreeItem*)pTree->GetItemData (hSelected); if (pItem->IsNoItem() || pItem->IsErrorItem()) { pTabDlg->DisplayPage (NULL); return TRUE; } if (pItem->ItemDisplaysNoPage()) { CString caption = pItem->ItemNoPageCaption(); pTabDlg->DisplayPage (NULL, caption); return TRUE; } if (pItem->HasReplicMonitor()) { pDoc->InitializeReplicator(pItem->GetDBName()); } int nImage = -1, nSelectedImage = -1; CImageList* pImageList = pTree->GetImageList (TVSIL_NORMAL); HICON hIcon = NULL; int nImageCount = pImageList? pImageList->GetImageCount(): 0; if (pImageList && pTree->GetItemImage(hSelected, nImage, nSelectedImage)) { if (nImage < nImageCount) hIcon = pImageList->ExtractIcon(nImage); } CuPageInformation* pPageInfo = pItem->GetPageInformation(); ASSERT(pPageInfo); if (!pPageInfo) return FALSE; int nSelectTab = GetDefaultSelectTab (pDoc); 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, NULL, nSelectTab); return TRUE; } catch(CMemoryException* e) { theApp.OutOfMemoryMessage(); e->Delete(); } catch(CResourceException* e) { AfxMessageBox (IDS_E_LOAD_DLG); e->Delete(); } catch(...) { AfxMessageBox (IDS_E_CONSTRUCT_PROPERTY); } return FALSE; }
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; }