update for HEAD-2003091401
[reactos.git] / subsys / system / explorer / Seashell / SeaShellExt / IEShellListView.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 // IEShellListView.cpp : implementation file
19 #include "stdafx.h"
20 #include "UIRes.h"
21 #include "IEShellListView.h"
22
23 #ifdef _DEBUG
24 #define new DEBUG_NEW
25 #undef THIS_FILE
26 static char THIS_FILE[] = __FILE__;
27 #endif
28
29 /////////////////////////////////////////////////////////////////////////////
30 // CIEShellListView
31
32 IMPLEMENT_DYNCREATE(CIEShellListView,CUIListView)
33
34 CIEShellListView::CIEShellListView()
35  : CUIListView(IDC_LIST_SHELL)
36 {
37         m_pActiveWnd = NULL;
38 }
39
40
41 CIEShellListView::~CIEShellListView()
42 {
43 }
44
45 void CIEShellListView::SetActiveWindow(CWnd *pWnd)
46 {
47         ASSERT_VALID(pWnd);
48         if (pWnd->GetSafeHwnd() == NULL)
49                 return;
50         if (m_pActiveWnd->GetSafeHwnd() == pWnd->GetSafeHwnd())
51                 return;
52         CRect rect;     
53         m_pActiveWnd->GetWindowRect(rect);
54         ScreenToClient(&rect);
55         m_pActiveWnd->ShowWindow(SW_HIDE);
56
57         m_pActiveWnd = pWnd;
58         m_pActiveWnd->ShowWindow(SW_SHOW);
59         m_pActiveWnd->MoveWindow(&rect);
60 }
61
62 void CIEShellListView::LoadShellFolderItems(const CRefreshShellFolder &rFolder)
63 {
64         LPTVITEMDATA lptvid = reinterpret_cast<LPTVITEMDATA>(rFolder.GetItemData());
65         if (lptvid == NULL)
66                 return;
67         GetShellListCtrl().Populate(lptvid);
68 }
69
70 BEGIN_MESSAGE_MAP(CIEShellListView, CUIListView)
71         //{{AFX_MSG_MAP(CIEShellListView)
72         ON_MESSAGE(WM_SETMESSAGESTRING,OnSetmessagestring)
73         ON_MESSAGE(WM_APP_UPDATE_ALL_VIEWS,OnAppUpdateAllViews)
74         ON_WM_SIZE()
75                 // NOTE - the ClassWizard will add and remove mapping macros here.
76         //}}AFX_MSG_MAP
77         ON_MESSAGE(WM_APP_CB_IE_SEL_CHANGE,OnCBIESelChange)
78         ON_MESSAGE(WM_APP_CB_IE_HIT_ENTER,OnCBIEHitEnter)
79 END_MESSAGE_MAP()
80
81 /////////////////////////////////////////////////////////////////////////////
82 // CIEShellListView message handlers
83
84 void CIEShellListView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
85 {
86         // TODO: Add your specialized code here and/or call the base class
87         if (lHint == HINT_TREE_SEL_CHANGED)
88         {
89                 GetListCtrl().SendMessage(WM_APP_UPDATE_ALL_VIEWS,(WPARAM)lHint,(LPARAM)pHint);
90         }       
91 }
92
93 void CIEShellListView::CreateListCtrl()
94 {
95         // TODO: Add your specialized code here and/or call the base class
96         m_pListCtrl = new CIEShellListCtrl;
97         m_pActiveWnd = m_pListCtrl;
98 }
99
100 CIEShellListCtrl &CIEShellListView::GetShellListCtrl()
101 {
102         // TODO: Add your specialized code here and/or call the base class
103
104         return static_cast<CIEShellListCtrl&>(GetListCtrl());
105 }
106
107 LRESULT CIEShellListView::OnAppUpdateAllViews(WPARAM wParam, LPARAM lParam)
108 {
109         if (wParam == HINT_TREE_INTERNET_FOLDER_SELECTED)
110         {
111                 if (lParam)
112                 {
113                         if (m_htmlCtrl.GetSafeHwnd() == NULL)
114                         {
115                                 if (m_htmlCtrl.Create(NULL,                                     // class name
116                                         NULL,                                                                   // title
117                                         (WS_CHILD | WS_VISIBLE),                                // style
118                                         CRect(),                                                                // rectangle
119                                         this,                                                                   // parent
120                                         2000,                                                                   // control ID
121                                         NULL))                                                                  // frame/doc context not use
122                                 {
123                                         m_htmlCtrl.SetNotifyWnd(GetParentFrame()->GetSafeHwnd());
124                                         m_htmlCtrl.GoHome();
125                                 }
126                         }
127                         else
128                                 GetParentFrame()->SendMessage(WM_APP_CB_IE_SET_EDIT_TEXT,(WPARAM)(LPCTSTR)m_htmlCtrl.GetLocationURL(),0);       
129                         SetActiveWindow(&m_htmlCtrl);
130                 }
131                 else
132                         SetActiveWindow(m_pListCtrl);
133         }
134         return 1;
135 }
136
137 void CIEShellListView::OnSize(UINT nType, int cx, int cy) 
138 {
139         // TODO: Add your message handler code here
140         if (m_pActiveWnd && m_pActiveWnd->GetSafeHwnd())
141                 m_pActiveWnd->MoveWindow(0,0,cx,cy);    
142         else
143                 CView::OnSize(nType, cx, cy);
144 }
145
146 LRESULT CIEShellListView::OnCBIESelChange(WPARAM wParam,LPARAM lParam)
147 {
148         if (m_pActiveWnd->GetSafeHwnd() == m_htmlCtrl.GetSafeHwnd())
149         {
150                 ASSERT(lParam);
151                 if (lParam)
152                         m_htmlCtrl.Navigate((LPCTSTR)lParam);
153         }
154         return 1L;
155 }
156
157 LRESULT CIEShellListView::OnCBIEHitEnter(WPARAM wParam,LPARAM lParam)
158 {
159         if (m_pActiveWnd->GetSafeHwnd() == m_htmlCtrl.GetSafeHwnd())
160         {
161                 ASSERT(lParam);
162                 if (lParam)
163                         m_htmlCtrl.Navigate((LPCTSTR)lParam);
164         }
165         return 1L;
166 }
167
168 LRESULT CIEShellListView::OnSetmessagestring(WPARAM wParam, LPARAM lParam)
169 {
170         CFrameWnd *pFrame = GetParentFrame();
171         if (pFrame)
172                 return pFrame->SendMessage(WM_SETMESSAGESTRING,wParam,lParam);
173         return 0;
174 }