IEView.cpp
上传用户:huashan618
上传日期:2013-03-26
资源大小:261k
文件大小:5k
源码类别:

浏览器

开发平台:

Visual C++

  1. // IEView.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "IEView.h"
  5. #include "resource.h"
  6. #include "..\PPExplorer.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. #include "..\myframewnd.h"
  13. #include ".ieview.h"
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CIEView
  16. extern CMyFrameWnd* g_frame;
  17. extern CPPExplorerApp theApp;
  18. IMPLEMENT_DYNCREATE(CIEView, CHtmlView)
  19. CIEView::CIEView()
  20. {
  21. //{{AFX_DATA_INIT(CIEView)
  22. // m_showStatus=FALSE;
  23. //}}AFX_DATA_INIT
  24. }
  25. CIEView::~CIEView()
  26. {
  27. }
  28. void CIEView::DoDataExchange(CDataExchange* pDX)
  29. {
  30. CHtmlView::DoDataExchange(pDX);
  31. //{{AFX_DATA_MAP(CIEView)
  32. // NOTE: the ClassWizard will add DDX and DDV calls here
  33. //}}AFX_DATA_MAP
  34. }
  35. BEGIN_MESSAGE_MAP(CIEView, CHtmlView)
  36. //{{AFX_MSG_MAP(CIEView)
  37. // NOTE - the ClassWizard will add and remove mapping macros here.
  38. //}}AFX_MSG_MAP
  39. ON_WM_CREATE()
  40. END_MESSAGE_MAP()
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CIEView diagnostics
  43. #ifdef _DEBUG
  44. void CIEView::AssertValid() const
  45. {
  46. CHtmlView::AssertValid();
  47. }
  48. void CIEView::Dump(CDumpContext& dc) const
  49. {
  50. CHtmlView::Dump(dc);
  51. }
  52. #endif //_DEBUG
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CIEView message handlers
  55. void CIEView::OnInitialUpdate() 
  56. {
  57. //TODO: This code navigates to a popular spot on the web.
  58. //Change the code to go where you'd like.
  59. //Navigate2(_T("http://www.microsoft.com/visualc/"),NULL,NULL);
  60. //主动调整大小
  61. GoHome();
  62. }
  63. BOOL CIEView::PreCreateWindow(CREATESTRUCT& cs) 
  64. {
  65. cs.style=WS_CHILD|WS_VISIBLE|WS_BORDER;
  66. return CHtmlView::PreCreateWindow(cs);
  67. }
  68. void CIEView::OnTitleChange(LPCTSTR lpszText) 
  69. {
  70. SetTabItemText(lpszText);
  71. m_strTitle=lpszText;
  72. CHtmlView::OnTitleChange(lpszText);
  73. }
  74. void CIEView::OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel) 
  75. {
  76. CRect rc;
  77. GetParent()->GetClientRect(&rc);
  78. SendMessage(WM_SIZE,SIZE_MAXSHOW,MAKELPARAM(rc.Width(),rc.Height()));
  79. if(m_bActivedWnd && IsWindowVisible())
  80. {
  81. g_frame->SetAddressBarText(GetLocationURL());
  82. m_strTitle=lpszURL;
  83. }
  84. if(!GetStatusBar())
  85. {
  86. //MessageBox("aaa");
  87. }
  88. CHtmlView::OnBeforeNavigate2(lpszURL, nFlags, lpszTargetFrameName, baPostedData, lpszHeaders, pbCancel);
  89. }
  90. void CIEView::OnNavigateComplete2(LPCTSTR strURL) 
  91. {
  92. g_frame->AddHistory(strURL,m_strTitle);
  93. if(m_bActivedWnd  && IsWindowVisible())
  94. {
  95. g_frame->SetAddressBarText(GetLocationURL());
  96. COleVariant vaZoomFactor;
  97. ExecWB(OLECMDID_ZOOM,OLECMDEXECOPT_DONTPROMPTUSER,NULL,&vaZoomFactor);
  98. }
  99. CHtmlView::OnNavigateComplete2(strURL);
  100. }
  101. //获取系统传来的创建一新窗口的消息,在本系统中,增加一新的TAB窗口
  102. void CIEView::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel) 
  103. {
  104. // TODO: Add your specialized code here and/or call the base class
  105. Cancel=FALSE;
  106. LRESULT pResult=theApp.m_pMainWnd->SendMessage(WM_NEW_IEVIEW);//g_frame->SendMessage(WM_NEW_IEVIEW);//AfxGetMainWnd()->SendMessage(WM_NEW_IEVIEW);
  107. if(!pResult) 
  108. {
  109. AfxMessageBox("所创建的新窗口不存在!");
  110. return;
  111. }g_frame->SetAddressBarText(GetLocationURL());
  112. CWnd* pWnd=(CWnd*)pResult;
  113. ASSERT(pWnd->IsKindOf(RUNTIME_CLASS(CIEView)));
  114. *ppDisp=((CIEView*)pWnd)->GetApplication();
  115. //CHtmlView::OnNewWindow2(ppDisp, Cancel);
  116. }
  117. BOOL CIEView::SetTabItemText(LPCTSTR lpszItem)
  118. {
  119.     g_frame->SetTabCtrlTitle(lpszItem);
  120. return TRUE;
  121. }
  122. void CIEView::ReadUrlDocument(LPCTSTR lpszUrl)
  123. {
  124. Navigate2(lpszUrl,NULL,NULL);
  125. }
  126. void CIEView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
  127. {
  128. // TODO: Add your specialized code here and/or call the base class
  129. /* if(bActivate && IsWindowVisible())
  130. {
  131. SetUrlAddress(GetLocationURL());
  132. ((CMainFrame*)AfxGetMainWnd())->SetWindowTextX(m_strTitle);
  133. COleVariant vaZoomFactor;
  134. ExecWB(OLECMDID_ZOOM,OLECMDEXECOPT_DONTPROMPTUSER,NULL,&vaZoomFactor);
  135. ((CMainFrame*)AfxGetMainWnd())->SetFontSizeVal(vaZoomFactor.intVal*10+1);
  136. EnableFrameButton();
  137. }
  138. m_bActivedWnd=bActivate;*/
  139. CHtmlView::OnActivateView(bActivate, pActivateView, pDeactiveView);
  140. }
  141. void CIEView::OnDocumentComplete(LPCTSTR lpszURL) 
  142.      CHtmlView::OnDocumentComplete(lpszURL);
  143. }
  144. CString CIEView::GetTitle()
  145. {
  146. return m_strTitle;
  147. }
  148. //通知程序,WEB浏览器命令的激活状态已修改
  149. void CIEView::OnCommandStateChange(long nCommand, BOOL bEnable) 
  150. {
  151. // TODO: Add your specialized code here and/or call the base class
  152. if(nCommand==1)//前进
  153. {
  154. m_bEnableGoForward=bEnable;
  155. }
  156. if(nCommand==2)//后退
  157. {
  158. m_bEnableGoBack=bEnable;
  159. }
  160. if(m_bActivedWnd && IsWindowVisible())
  161. {
  162. EnableFrameButton();
  163. }
  164. CHtmlView::OnCommandStateChange(nCommand, bEnable);
  165. }
  166. void CIEView::EnableFrameButton()
  167. {
  168. g_frame->EnableGoBack(m_bEnableGoBack);
  169. g_frame->EnableGoForward(m_bEnableGoForward);
  170. }
  171. void CIEView::OnStatusTextChange(LPCTSTR lpszText)
  172. {
  173. CHtmlView::OnStatusTextChange(lpszText);
  174. ::PostMessage(m_hostwnd,WM_STATUS_MESSAGE,0,(LPARAM)lpszText);
  175. }
  176. int CIEView::OnCreate(LPCREATESTRUCT lpCreateStruct)
  177. {
  178. if (CHtmlView::OnCreate(lpCreateStruct) == -1)
  179. return -1;
  180. m_hostwnd=lpCreateStruct->hwndParent;
  181. return 0;
  182. }