BOOL CGridDevListCtrl::InitDevList(void) { // Create and attach image list m_ImgList.Create(16, 16, ILC_COLOR16 | ILC_MASK, 1, 0); RemoveAllGroups(); // TODO: Add List Images // m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_FLGDEN)); SetImageList(&m_ImgList, LVSIL_SMALL); // Give better margin to editors SetCellMargin(1.2); CGridRowTraitText* pRowTrait = new CGridRowTraitXP; SetDefaultRowTrait(pRowTrait); InsertHiddenLabelColumn(); // Requires one never uses column 0 CString sColTitle; CGridColumnTraitText* gridColText; int colIndex = 0; int colWidth; gridColText = new CGridColumnTraitText; sColTitle.LoadString(IDS_VENDOR_ID); colWidth = 100; colIndex++; gridColText->SetMetaFlag(GCSF_FIXED, true); InsertColumnTrait(colIndex, sColTitle, LVCFMT_LEFT, colWidth, colIndex, gridColText); gridColText = new CGridColumnTraitText; sColTitle.LoadString(IDS_PRODUCT_ID); colWidth = 100; colIndex++; gridColText->SetMetaFlag(GCSF_FIXED, true); InsertColumnTrait(colIndex, sColTitle, LVCFMT_LEFT, colWidth, colIndex, gridColText); gridColText = new CGridColumnTraitText; sColTitle.LoadString(IDS_DESCRIPTION); colIndex++; gridColText->SetMetaFlag(GCSF_FIXED, false); InsertColumnTrait(colIndex, sColTitle, LVCFMT_LEFT, colWidth, colIndex, gridColText); gridColText = new CGridColumnTraitText; sColTitle.LoadString(IDS_INSTALLED_DRIVER); colWidth = 150; colIndex++; gridColText->SetMetaFlag(GCSF_FIXED, true); InsertColumnTrait(colIndex, sColTitle, LVCFMT_LEFT, colWidth, colIndex, gridColText); CViewConfigSectionWinApp* pColumnProfile = new CViewConfigSectionWinApp(_T("Device List")); pColumnProfile->AddProfile(_T("Default")); SetupColumnConfig(pColumnProfile); UpdateDevList(TRUE); return TRUE; // return TRUE unless you set the focus to a control }
void CFeedIcoItemListCtrl::FilterItemsBySearchKey(CString* pSearchKey) { if (!IsWindowVisible()) return; if (pSearchKey == NULL || pSearchKey->IsEmpty()) { if (m_stringMatcher.IsOriginal()) return; } const StringMatcher::ListItemsNeedShow& listItemsNeedShow = m_stringMatcher.GetMatchResult(pSearchKey); SetRedraw(FALSE); RemoveAllGroups();//删除分组 RemoveAllGroupData();//删除m_mapGroups DeleteAllItems();//删除items for (StringMatcher::ListItemsNeedShow::const_iterator ix = listItemsNeedShow.begin(); ix != listItemsNeedShow.end(); ++ix) { CRssFeed* listKey = (CRssFeed*)*ix; CString strCaption = GetExtentString( listKey->GetDisplayName() ); int nRet = InsertItem(GetItemCount(), strCaption); this->SetItemData(nRet, LPARAM(listKey)); } GroupAllFeedsByType(0); SetRedraw(TRUE); }
void ShutdownStrategicLayer() { DeleteAllStrategicEvents(); RemoveAllGroups(); TrashUndergroundSectorInfo(); DeleteCreatureDirectives(); KillStrategicAI(); }
//------------------------------------------------------------------------ //! Create a group for each unique values within a column //! //! @param nCol The index of the column //! @return Succeeded in creating the group //------------------------------------------------------------------------ BOOL CGridListCtrlGroups::GroupByColumn(int nCol) { CWaitCursor waitCursor; SetSortArrow(-1, false); SetRedraw(FALSE); RemoveAllGroups(); EnableGroupView( GetItemCount() > 0 ); if (IsGroupViewEnabled()) { CSimpleMap<CString,CSimpleArray<int> > groups; // Loop through all rows and find possible groups for(int nRow=0; nRow<GetItemCount(); ++nRow) { CString cellText = GetItemText(nRow, nCol); int nGroupId = groups.FindKey(cellText); if (nGroupId==-1) { CSimpleArray<int> rows; groups.Add(cellText, rows); nGroupId = groups.FindKey(cellText); } groups.GetValueAt(nGroupId).Add(nRow); } // Look through all groups and assign rows to group for(int nGroupId = 0; nGroupId < groups.GetSize(); ++nGroupId) { const CSimpleArray<int>& groupRows = groups.GetValueAt(nGroupId); DWORD dwState = LVGS_NORMAL; #ifdef LVGS_COLLAPSIBLE if (IsGroupStateEnabled()) dwState = LVGS_COLLAPSIBLE; #endif VERIFY( InsertGroupHeader(nGroupId, nGroupId, groups.GetKeyAt(nGroupId), dwState) != -1); for(int groupRow = 0; groupRow < groupRows.GetSize(); ++groupRow) { VERIFY( SetRowGroupId(groupRows[groupRow], nGroupId) ); } } SetRedraw(TRUE); Invalidate(FALSE); return TRUE; } SetRedraw(TRUE); Invalidate(FALSE); return FALSE; }
// ************************************************************************** // Stop () // // Description: // Remove all OPC Groups from OPC Server and disconnect. Our CKGroup // objects will not be deleted at this point. We will delete them when // they are actually removed from project. // // Parameters: // none // // Returns: // void // ************************************************************************** void CKServer::Stop () { // Remove all OPC Groups. Passing "false" will prevent our CKGroups // from being deleted. RemoveAllGroups (false); // Disconnect from the OPC Server we are connected to: Disconnect (); }
//***************************************************************************************** void CBCGPToolBoxEx::RemoveAllToolsPages () { ASSERT_VALID (this); for (int i = 0; i < (int) m_lstTaskGroups.GetCount (); i++) { CBCGPToolBoxPage* pPage = GetPage (i); ASSERT_VALID (pPage); pPage->DestroyWindow (); } RemoveAllGroups (); }
// ************************************************************************** // ~CKServer () // // Description: // Destructor. // // Parameters: // none // // Returns: // none // ************************************************************************** CKServer::~CKServer () { // Remove all groups: RemoveAllGroups (); // Disconnect from the OPC Sserver we are connected to: Disconnect (); // Assert that all interfaces and groups have been properly released: ASSERT (m_cdwGroups == 0); ASSERT (m_pIServer == NULL); ASSERT (m_pICommon == NULL); ASSERT (m_pIConnPtContainer == NULL); ASSERT (m_pIItemProps == NULL); ASSERT (m_pIBrowse == NULL); ASSERT (m_pIPublicGroups == NULL); ASSERT (m_pIPersistFile == NULL); ASSERT (m_pIShutdownSink == NULL); ASSERT (m_dwCookieShutdownSink == 0); }
//------------------------------------------------------------------------ //! Override this method to change the context menu when activating context //! menu in client area with no rows //! //! @param pWnd Handle to the window in which the user right clicked the mouse //! @param point Position of the cursor, in screen coordinates, at the time of the mouse click. //------------------------------------------------------------------------ void CGridListCtrlGroups::OnContextMenuGrid(CWnd* pWnd, CPoint point) { if (IsGroupStateEnabled()) { CMenu menu; UINT uFlags = MF_BYPOSITION | MF_STRING; VERIFY( menu.CreatePopupMenu() ); menu.InsertMenu(0, uFlags, 1, _T("Expand all groups")); menu.InsertMenu(1, uFlags, 2, _T("Collapse all groups")); menu.InsertMenu(2, uFlags, 3, _T("Disable grouping")); int nResult = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD, point.x, point.y, this, 0); switch(nResult) { case 1: ExpandAllGroups(); break; case 2: CollapseAllGroups(); break; case 3: RemoveAllGroups(); EnableGroupView(FALSE); break; } } }
//------------------------------------------------------------------------ //! Override this method to change the context menu when activating context //! menu for the column headers //! //! @param pWnd Handle to the window in which the user right clicked the mouse //! @param point Position of the cursor, in screen coordinates, at the time of the mouse click. //! @param nCol The index of the column //------------------------------------------------------------------------ void CGridListCtrlGroups::OnContextMenuHeader(CWnd* pWnd, CPoint point, int nCol) { // Only Windows XP and above supports groups if (!IsCommonControlsEnabled()) { CGridListCtrlEx::OnContextMenuHeader(pWnd, point, nCol); return; } // Show context-menu with the option to show hide columns CMenu menu; VERIFY( menu.CreatePopupMenu() ); if (nCol!=-1) { // Retrieve column-title const CString& columnTitle = GetColumnHeading(nCol); menu.AppendMenu(MF_STRING, 3, CString(_T("Group by: ")) + columnTitle); } if (IsGroupViewEnabled()) { menu.AppendMenu(MF_STRING, 4, _T("Disable grouping")); } CString title_editor; if (HasColumnEditor(nCol, title_editor)) { menu.AppendMenu(MF_STRING, 1, static_cast<LPCTSTR>(title_editor)); } CString title_picker; if (HasColumnPicker(title_picker)) { menu.AppendMenu(MF_STRING, 2, static_cast<LPCTSTR>(title_picker)); } else { if (menu.GetMenuItemCount()>0) menu.AppendMenu(MF_SEPARATOR, 0, _T("")); InternalColumnPicker(menu, 6); } CSimpleArray<CString> profiles; InternalColumnProfileSwitcher(menu, GetColumnCount() + 7, profiles); CString title_resetdefault; if (HasColumnDefaultState(title_resetdefault)) { if (profiles.GetSize()==0) menu.AppendMenu(MF_SEPARATOR, 0, _T("")); menu.AppendMenu(MF_STRING, 5, title_resetdefault); } // Will return zero if no selection was made (TPM_RETURNCMD) int nResult = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD, point.x, point.y, this, 0); switch(nResult) { case 0: break; case 1: OpenColumnEditor(nCol); break; case 2: OpenColumnPicker(); break; case 3: GroupByColumn(nCol); break; case 4: { // Very strange problem when disabling group mode, then scrollbars are not updated // If placed in the bottom and disables group mode, then suddenly there is a strange offset // - Quick fix scroll to top, and then fix scroll bars afterwards int pos = GetScrollPos(SB_VERT); EnsureVisible(0,FALSE); RemoveAllGroups(); EnableGroupView(FALSE); Scroll(CSize(0,pos)); } break; case 5: ResetColumnDefaultState(); break; default: { int nCol = nResult-6; if (nCol < GetColumnCount()) { ShowColumn(nCol, !IsColumnVisible(nCol)); } else { int nProfile = nResult-GetColumnCount()-7; SwichColumnProfile(profiles[nProfile]); } } break; } }
BOOL CFeedIcoItemListCtrl::GroupAllFeedsByType(int nType) { if (!IsCommonControlsEnabled()) return FALSE; SetRedraw(FALSE); RemoveAllGroups(); RemoveAllGroupData(); EnableGroupView( GetItemCount() > 0 ); if (IsGroupViewEnabled()) { // Loop through all rows and find possible groups for(int nItem = 0; nItem < GetItemCount(); nItem++ ) { CString strCatalogName = GetResString( IDS_UNKNOWN ); CRssFeed* pFeed = (CRssFeed*)GetItemData(nItem); if (pFeed == NULL) continue; if ( pFeed->m_uCatalogId != FeedCatalog::INVALID_CATALOG_ID ) { FeedCatalog & catalog = CFeedCatalogs::GetInstance()[pFeed->m_uCatalogId]; ASSERT(catalog.m_uId == pFeed->m_uCatalogId); ASSERT(catalog.IsLeaf()); FeedCatalog * catalogParent; if (catalog.m_pParent != NULL) { catalogParent = catalog.m_pParent; strCatalogName = catalogParent->m_strName; } } int nGroupId = m_mapGroups.FindKey(strCatalogName); if (nGroupId == -1) { CSimpleArray<int> nItems; m_mapGroups.Add(strCatalogName, nItems); nGroupId = m_mapGroups.FindKey(strCatalogName); } //必须添加不重复数据 if (m_mapGroups.GetValueAt(nGroupId).Find(nItem) == -1) { m_mapGroups.GetValueAt(nGroupId).Add(nItem); } } // Look through all groups and assign rows to group for(int nGroupId = 0; nGroupId < m_mapGroups.GetSize(); nGroupId++) { const CSimpleArray<int>& groupRows = m_mapGroups.GetValueAt(nGroupId); DWORD dwState = LVGS_NORMAL; #ifdef LVGS_COLLAPSIBLE if (IsGroupStateEnabled()) dwState = LVGS_COLLAPSIBLE; #endif VERIFY( InsertTypeGroup(nGroupId, nGroupId, m_mapGroups.GetKeyAt(nGroupId), dwState) != -1); for(int groupRow = 0; groupRow < groupRows.GetSize(); ++groupRow) { VERIFY( SetItemGroupId(groupRows[groupRow], nGroupId) ); } } } SetRedraw(TRUE); Invalidate(TRUE); return FALSE; }