// ctrlext.cpp : implementation file // // This is a part of the Microsoft Foundation Classes and // Templates (MFC&T). // Copyright (C) 1998 Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // MFC&T Reference and related electronic documentation provided // with the library. See these sources for detailed information // regarding the MFC&T product. // #include "stdafx.h" #include "DBViewer.h" #include "ctrlext.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CTreeCursor const CTreeCursor& CTreeCursor::operator =(const CTreeCursor& posSrc) { if(&posSrc != this){ m_hTreeItem = posSrc.m_hTreeItem; m_pTree = posSrc.m_pTree; } return *this; } CTreeCursor CTreeCursor::_Insert(LPCTSTR strItem,int nImageIndex,HTREEITEM hAfter) { TV_INSERTSTRUCT ins; ins.hParent = m_hTreeItem; ins.hInsertAfter = hAfter; ins.item.mask = TVIF_TEXT; ins.item.pszText = (LPTSTR) strItem; if(nImageIndex != -1){ ins.item.mask |= TVIF_IMAGE | TVIF_SELECTEDIMAGE; ins.item.iImage = nImageIndex; ins.item.iSelectedImage = nImageIndex; } return CTreeCursor(m_pTree->InsertItem(&ins), m_pTree); } int CTreeCursor::GetImageID() { TV_ITEM item; item.mask = TVIF_HANDLE | TVIF_IMAGE; item.hItem = m_hTreeItem; m_pTree->GetItem(&item); return item.iImage; } ///////////////////////////////////////////////////////////////////////////// // CListCtrlEx BOOL CListCtrlEx::AddColumn(LPCTSTR strItem,int nItem,int nSubItem,int nMask,int nFmt) { LV_COLUMN lvc; lvc.mask = nMask; lvc.fmt = nFmt; lvc.pszText = (LPTSTR) strItem; lvc.cx = GetStringWidth(lvc.pszText) + 15; if(nMask & LVCF_SUBITEM){ if(nSubItem != -1) lvc.iSubItem = nSubItem; else lvc.iSubItem = nItem; } return InsertColumn(nItem,&lvc); } BOOL CListCtrlEx::AddItem(int nItem,int nSubItem,LPCTSTR strItem,int nImageIndex) { LV_ITEM lvItem; lvItem.mask = LVIF_TEXT; lvItem.iItem = nItem; lvItem.iSubItem = nSubItem; lvItem.pszText = (LPTSTR) strItem; if(nImageIndex != -1){ lvItem.mask |= LVIF_IMAGE; lvItem.iImage |= LVIF_IMAGE; } if(nSubItem == 0) return InsertItem(&lvItem); return SetItem(&lvItem); } BEGIN_MESSAGE_MAP(CListCtrlEx, CListCtrl) //{{AFX_MSG_MAP(CListCtrlEx) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CListCtrlEx message handlers ///////////////////////////////////////////////////////////////////////////// // CTreeCtrlEx // All Handled by Inlines BEGIN_MESSAGE_MAP(CTreeCtrlEx, CTreeCtrl) //{{AFX_MSG_MAP(CTreeCtrlEx) // NOTE - the ClassWizard will add and remove mapping macros here. //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CTreeCtrlEx message handlers