IEShellListView.cpp
上传用户:yatsl7111
上传日期:2007-01-08
资源大小:1433k
文件大小:5k
源码类别:

图形图象

开发平台:

Visual C++

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