BOOL CuDlgIpmTabCtrl::OnInitDialog() { CDialog::OnInitDialog(); VERIFY (m_staticHeader.SubclassDlgItem (IDC_STATIC, this)); m_staticHeader.SetImage (-1); // No Image for Now CWnd* pParent1 = GetParent(); // The view: CImView2 ASSERT (pParent1); CdIpmDoc* pDoc = (CdIpmDoc*)((CView*)pParent1)->GetDocument(); ASSERT (pDoc); if (!pDoc->GetCurrentProperty()) return TRUE; // // When the document is Loaded ... try { CfIpmFrame* pFrame = (CfIpmFrame*)GetParentFrame(); CvIpmLeft* pIpmView1= (CvIpmLeft*)pFrame->GetLeftPane(); CTreeCtrl& treeCtrl = pIpmView1->GetTreeCtrl(); HTREEITEM hSelected= treeCtrl.GetSelectedItem (); ASSERT (hSelected); if (!hSelected) return TRUE; CTreeItem* pItem = (CTreeItem*)treeCtrl.GetItemData (hSelected); CuPageInformation* pPageInfo = pDoc->GetCurrentProperty()->GetPageInfo(); LPIPMUPDATEPARAMS pUps = pPageInfo->GetUpdateParam(); pUps->nType = pItem->GetType(); pUps->pStruct = pItem->GetPTreeItemData()? pItem->GetPTreeItemData()->GetDataPtr(): NULL; pUps->pSFilter= pDoc->GetFilter(); int nImage = -1, nSelectedImage = -1; CImageList* pImageList = treeCtrl.GetImageList (TVSIL_NORMAL); HICON hIcon = NULL; int nImageCount = pImageList? pImageList->GetImageCount(): 0; if (pImageList && treeCtrl.GetItemImage(hSelected, nImage, nSelectedImage)) { if (nImage < nImageCount) hIcon = pImageList->ExtractIcon(nImage); } pPageInfo->SetImage (hIcon); LoadPage (pDoc->GetCurrentProperty()); m_bIsLoading = TRUE; if (m_pCurrentPage) { UINT nMask = IPMMASK_FONT|IPMMASK_SHOWGRID; m_pCurrentPage->SendMessage (WMUSRMSG_CHANGE_SETTING, (UINT)nMask, (LPARAM)&(pDoc->GetProperty())); } } catch (CMemoryException* e) { theApp.OutOfMemoryMessage (); m_pCurrentPage = NULL; m_pCurrentProperty = NULL; e->Delete(); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CIpmCtrl::Initiate(LPCTSTR lpszNode, LPCTSTR lpszServer, LPCTSTR lpszUser, LPCTSTR lpszOption) { BOOL bOK = FALSE; if (m_pIpmFrame) { m_pIpmFrame->ShowWindow (SW_HIDE); m_pIpmFrame->DestroyWindow(); m_pIpmFrame = NULL; } CWnd* pParent = this; CRect r; GetClientRect (r); m_pIpmFrame = new CfIpmFrame(); m_pIpmFrame->Create ( NULL, NULL, WS_CHILD, r, pParent); m_pIpmFrame->InitialUpdateFrame(NULL, TRUE); m_pIpmFrame->ShowWindow(SW_HIDE); CdIpmDoc* pDoc = m_pIpmFrame->GetIpmDoc(); ASSERT(pDoc); if (pDoc) { CaIpmProperty& property = pDoc->GetProperty(); ConstructPropertySet (property); UINT nMask = IPMMASK_TIMEOUT|IPMMASK_BKREFRESH|IPMMASK_SHOWGRID|IPMMASK_FONT|IPMMASK_MAXSESSION; IPM_PropertiesChange((WPARAM)nMask, (LPARAM)&property); theApp.SetRefreshFrequency(m_refreshFrequency); theApp.SetActivateBkRefresh(m_activateRefresh); theApp.StartBackgroundRefreshThread(); } ASSERT(m_pIpmFrame); // Must create the window first if (!m_pIpmFrame) return FALSE; if (pDoc) { SFILTER* pFilter = theApp.GetFilter(); SFILTER* pDocFilter = pDoc->GetFilter(); memcpy (pDocFilter, pFilter, sizeof(SFILTER)); bOK = pDoc->Initiate(lpszNode, lpszServer, lpszUser, lpszOption); } if (!bOK) { m_pIpmFrame->ShowWindow (SW_HIDE); m_pIpmFrame->DestroyWindow(); m_pIpmFrame = NULL; return bOK; } m_pIpmFrame->ShowWindow(SW_SHOW); return bOK; }
BOOL CIpmCtrl::UpdateFilters(short FAR* arrayFilter, short nArraySize) { SFILTER* pFilter = theApp.GetFilter(); ASSERT(nArraySize >= 5); int nPos = 0; pFilter->bNullResources = (BOOL)arrayFilter[nPos]; nPos++; pFilter->bInternalSessions = (BOOL)arrayFilter[nPos]; nPos++; pFilter->bSystemLockLists = (BOOL)arrayFilter[nPos]; nPos++; pFilter->bInactiveTransactions = (BOOL)arrayFilter[nPos]; nPos++; pFilter->ResourceType = arrayFilter[nPos]; nPos++; if (!m_pIpmFrame) return FALSE; CdIpmDoc* pDoc = m_pIpmFrame->GetIpmDoc(); ASSERT(pDoc); if (!pDoc) return FALSE; SFILTER* pDocFilter = pDoc->GetFilter(); memcpy (pDocFilter, pFilter, sizeof(SFILTER)); return TRUE; }
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; }