update for HEAD-2003091401
[reactos.git] / subsys / system / explorer / Seashell / SeaShellExt / IEShellTreeView.cpp
1 //*******************************************************************************
2 // COPYRIGHT NOTES
3 // ---------------
4 // You may use this source code, compile or redistribute it as part of your application 
5 // for free. You cannot redistribute it as a part of a software development 
6 // library without the agreement of the author. If the sources are 
7 // distributed along with the application, you should leave the original 
8 // copyright notes in the source code without any changes.
9 // This code can be used WITHOUT ANY WARRANTIES at your own risk.
10 // 
11 // For the latest updates to this code, check this site:
12 // http://www.masmex.com 
13 // after Sept 2000
14 // 
15 // Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
16 //*******************************************************************************
17
18 // IEShellTreeView.cpp : implementation file
19 #include "stdafx.h"
20 #include "UIRes.h"
21 #include "UIMessages.h"
22 #include "IEShellTreeView.h"
23
24 #ifdef _DEBUG
25 #define new DEBUG_NEW
26 #undef THIS_FILE
27 static char THIS_FILE[] = __FILE__;
28 #endif
29
30 /////////////////////////////////////////////////////////////////////////////
31 // CIEShellTreeView
32
33 IMPLEMENT_DYNCREATE(CIEShellTreeView,CUITreeView)
34
35 CIEShellTreeView::CIEShellTreeView()
36  : CUITreeView(IDC_TREE_SHELL)
37 {
38         m_bPopulated = false;
39 }
40
41
42 CIEShellTreeView::~CIEShellTreeView()
43 {
44 }
45
46 LPTVITEMDATA CIEShellTreeView::GetSelectedItemData()
47 {
48         HTREEITEM hItem = GetShellTreeCtrl().GetSelectedItem();
49         LPTVITEMDATA ptvid=NULL;
50         if (hItem)
51                 ptvid = (LPTVITEMDATA)GetShellTreeCtrl().GetItemData(hItem);
52         return ptvid;
53 }
54
55 void CIEShellTreeView::OnInitialUpdate() 
56 {
57         CUITreeView::OnInitialUpdate();
58         
59         // TODO: Add your specialized code here and/or call the base class
60         if (!m_bPopulated)
61         {
62                 GetShellTreeCtrl().SetComboBoxWnd(GetParentFrame()->GetSafeHwnd());
63                 PopulateTree(NULL);
64         }
65 }
66
67 bool CIEShellTreeView::PopulateTree(LPCTSTR pszPath)
68 {
69         CIEShellTreeCtrl *pCtrl = (CIEShellTreeCtrl*)m_pTreeCtrl;
70         m_bPopulated = pCtrl->LoadFolderItems(pszPath); 
71         return m_bPopulated;
72 }
73
74 void CIEShellTreeView::CreateTreeCtrl()
75 {
76         // TODO: Add your specialized code here and/or call the base class
77         m_pTreeCtrl = new CIEShellTreeCtrl;     
78 }
79
80 BEGIN_MESSAGE_MAP(CIEShellTreeView, CUITreeView)
81         //{{AFX_MSG_MAP(CIEShellTreeView)
82         ON_MESSAGE(WM_SETMESSAGESTRING,OnSetmessagestring)
83                 // NOTE - the ClassWizard will add and remove mapping macros here.
84         //}}AFX_MSG_MAP
85 END_MESSAGE_MAP()
86
87 /////////////////////////////////////////////////////////////////////////////
88 // CIEShellTreeView message handlers
89
90 void CIEShellTreeView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
91 {
92         if (bActivate && pDeactiveView != NULL)
93         {
94 //              theApp.SwitchTab(CViewTabView::TAB_LIST_FOLDER);
95                 GetTreeCtrl().SetFocus();
96         }
97         CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
98 }
99
100
101 LRESULT CIEShellTreeView::OnSetmessagestring(WPARAM wParam, LPARAM lParam)
102 {
103         CFrameWnd *pFrame = GetParentFrame();
104         if (pFrame)
105                 return pFrame->SendMessage(WM_SETMESSAGESTRING,wParam,lParam);
106         return 0;
107 }