【VC开源代码栏目提醒】:网学会员--在 VC开源代码编辑为广大网友搜集整理了:LEFTVIEW.CPP绩等信息,祝愿广大网友取得需要的信息,参考学习。
// LeftView.cpp : implementation file
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "LeftView.h"
#include "Demo_OutlookDoc.h"
#include "Demo_OutlookView.h"
#include "RightView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLeftView
IMPLEMENT_DYNCREATE(CLeftView, CTreeView)
CLeftView::CLeftView()
{
}
CLeftView::~CLeftView()
{
}
BEGIN_MESSAGE_MAP(CLeftView, CTreeView)
//{{AFX_MSG_MAP(CLeftView)
ON_WM_CREATE()
ON_NOTIFY_REFLECT(TVN_ITEMEXPANDING, OnItemexpanding)
ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelchanged)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLeftView drawing
void CLeftView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CLeftView diagnostics
#ifdef _DEBUG
void CLeftView::AssertValid() const
{
CTreeView::AssertValid();
}
void CLeftView::Dump(CDumpContext& dc) const
{
CTreeView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CLeftView message handlers
int CLeftView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CTreeView::OnCreate(lpCreateStruct) == -1)
return -1;
m_TreeCtrl = &GetTreeCtrl();
m_TreeCtrl->ModifyStyle (0, TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT);
m_Font.CreatePointFont (85, _T("Tahoma"));
m_TreeCtrl->SetFont (&m_Font);
PopulateTreeControls();
return 0;
}
static CString csTreeItems[] =
{
_T("Outlook Today - [Mailbox - Kirk Stowell]"),
_T("Public Folders"),
_T("Calendar"),
_T("Contacts"),
_T("Deleted Items (4)"),
_T("Drafts"),
_T("Inbox (50)"),
_T("Journal"),
_T("Notes"),
_T("Outbox"),
_T("Sent Items"),
_T("Tasks")
};
static UINT nImages[] =
{
IDI_ICON_OUTLOOK,
IDI_ICON_PUBLIC,
IDI_ICON_CALENDAR,
IDI_ICON_CONTACTS,
IDI_ICON_DELETED,
IDI_ICON_DRAFTS,
IDI_ICON_INBOX,
IDI_ICON_JOURNAL,
IDI_ICON_NOTES,
IDI_ICON_OUTBOX,
IDI_ICON_SENT,
IDI_ICON_TASKS
};
void CLeftView::PopulateTreeControls()
{
// create the image list for the tree control
// and set the tree style using defaults
// Set the image list for the menu control
m_ImageList.Create (16, 16, true, 2, 1);
HICON hIcon;
for (int i =0; i < 12; ++i) {
hIcon= AfxGetApp()->LoadIcon (nImages[i]);
m_ImageList.Add (hIcon);
}
m_TreeCtrl->SetImageList( &m_ImageList, TVSIL_NORMAL );
// add the parent items
m_htParent = m_TreeCtrl->InsertItem( csTreeItems[0], 0, 0 );
m_TreeCtrl->InsertItem( csTreeItems[1], 1, 1 );
// add childeren items
AddTreeChildren( m_htParent );
m_TreeCtrl->Expand(m_htParent, TVE_EXPAND);
}
void CLeftView::AddTreeChildren( HTREEITEM htiParent )
{
HTREEITEM hti1, hti2;
m_TreeCtrl->InsertItem( csTreeItems[2], 2, 2, htiParent );
m_TreeCtrl->InsertItem( csTreeItems[3], 3, 3,htiParent );
hti1 = m_TreeCtrl->InsertItem( csTreeItems[4], 4, 4, htiParent );
m_TreeCtrl->InsertItem( csTreeItems[5], 5, 5, htiParent );
hti2 = m_TreeCtrl->InsertItem( csTreeItems[6], 6, 6, htiParent );
m_TreeCtrl->InsertItem( csTreeItems[7], 7, 7, htiParent );
m_TreeCtrl->InsertItem( csTreeItems[8], 8, 8, htiParent );
m_TreeCtrl->InsertItem( csTreeItems[9], 9, 9, htiParent );
m_TreeCtrl->InsertItem( csTreeItems[10], 10, 10, htiParent );
m_TreeCtrl->InsertItem( csTreeItems[11], 11, 11, htiParent );
m_TreeCtrl->SetItemState( hti1, TVIS_BOLD, TVIS_BOLD );
m_TreeCtrl->SetItemState( hti2, TVIS_BOLD, TVIS_BOLD );
}
// GetLastItem - Gets last item in the branch
// Returns - Last item
// hItem - Node identifying the branch. NULL will
// return the last item in outine
HTREEITEM CLeftView::GetLastItem( HTREEITEM hItem )
{
// Last child of the last child of the last child ...
HTREEITEM htiNext;
if( hItem == NULL ){
// Get the last item at the top level
htiNext = m_TreeCtrl->GetRootItem();
while( htiNext ){
hItem = htiNext;
htiNext = m_TreeCtrl->GetNextSiblingItem( htiNext );
}
}
while( m_TreeCtrl->ItemHasChildren( hItem ) ){
htiNext = m_TreeCtrl->GetChildItem( hItem );
while( htiNext ){