ContainerView.cpp
上传用户:szcysw
上传日期:2013-03-11
资源大小:6752k
文件大小:4k
源码类别:

界面编程

开发平台:

Visual C++

  1. // ContainerView.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "TaxExpert.h"
  5. #include "ContainerView.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CContainerView
  13. IMPLEMENT_DYNCREATE(CContainerView, CHtmlView)
  14. CContainerView::CContainerView()
  15. {
  16. can=1;
  17. }
  18. CContainerView::~CContainerView()
  19. {
  20. }
  21. BEGIN_MESSAGE_MAP(CContainerView, CHtmlView)
  22. //{{AFX_MSG_MAP(CContainerView)
  23. //}}AFX_MSG_MAP
  24. END_MESSAGE_MAP()
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CContainerView drawing
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CContainerView diagnostics
  29. #ifdef _DEBUG
  30. void CContainerView::AssertValid() const
  31. {
  32. CHtmlView::AssertValid();
  33. }
  34. void CContainerView::Dump(CDumpContext& dc) const
  35. {
  36. CHtmlView::Dump(dc);
  37. }
  38. #endif //_DEBUG
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CContainerView message handlers
  41. void CContainerView::OnInitialUpdate() 
  42. {
  43. //TODO: This code navigates to a popular spot on the web.
  44. //Change the code to go where you'd like.
  45. ///this->getd
  46. LoadFromResource( IDR_WHATS_NEW );
  47. }
  48. void CContainerView::OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel) 
  49. {
  50. CHtmlView::OnBeforeNavigate2(lpszURL, nFlags, lpszTargetFrameName, baPostedData, lpszHeaders, pbCancel);
  51. }
  52. #include "TaxExpertDoc.h"
  53. void CContainerView::OnStatusTextChange(LPCTSTR lpszText) 
  54. {
  55. CString k(lpszText);
  56. CString g;
  57. this->u=k;
  58. CHtmlView::OnStatusTextChange(lpszText);
  59. }
  60. BOOL CContainerView::PreTranslateMessage(MSG* pMsg) 
  61. {
  62. // TODO: Add your specialized code here and/or call the base class
  63. if(!can)
  64. return 1;
  65. //if(pMsg->message==WM_RBUTTONDOWN)
  66. // return 1;
  67. if(pMsg->message==WM_LBUTTONDOWN)
  68. {
  69. if(u.Find("temp.htm?no")!=-1)
  70. {
  71. can=0;
  72. CString filename;
  73. filename=this->GenarateHtml(u.Mid(u.Find("=")+1));
  74. can=1;
  75. this->Navigate2(filename);
  76. //::SendMessage(AfxGetMainWnd()->m_hWnd,ID_FROM_HTML,0,0);
  77. return 0;
  78. }
  79. ////this->Navigate2("c:\");
  80. }
  81. return CHtmlView::PreTranslateMessage(pMsg);
  82. }
  83. CString CContainerView::GenarateHtml(CString num)
  84. {
  85. BeginWaitCursor();
  86. CString filename;
  87. CString content;
  88. TCHAR s[MAX_PATH];
  89. GetModuleFileName(NULL,s,MAX_PATH);
  90. TCHAR szDir[MAX_PATH];
  91. TCHAR szDrv[MAX_PATH];
  92. _splitpath(s,szDrv,szDir,NULL,NULL);
  93. CString htmlpath=(CString)szDrv+(CString)szDir;
  94. htmlpath+="kingdom/";
  95. filename=htmlpath+num;
  96. if(IsFileExist(filename))
  97. return filename;
  98. CString Header,tail,body,aftertile;
  99. //格式化的HTTML文件头及文件尾
  100. Header.LoadString(IDS_BANNER);
  101. tail="<hr color="#FF0000">";
  102. tail+="<p align="center"><span style="font-size: 9pt">税务师欢迎你</span></p>";
  103. CFile tempFile;
  104. filename=htmlpath+num+".html";
  105. CTaxExpertDoc * pDOC=(CTaxExpertDoc *)this->GetDocument();
  106. CString filter="[num]="+num;
  107. pDOC->m_pSet->m_strFilter=filter;
  108. pDOC->m_pSet->Requery();
  109. content=pDOC->m_pSet->m_content;
  110. if(content.IsEmpty())
  111. content="无法查看该文件";
  112. Header+=pDOC->m_pSet->m_fileName;
  113. aftertile.LoadString(IDS_BANNERAFTERTILE);
  114. //构造红头文件:标题+换行+文号
  115. Header+="<br>";
  116. Header+=pDOC->m_pSet->m_file_num;
  117. Header+=aftertile;
  118. tempFile.Open(filename,CFile::modeCreate|CFile::modeReadWrite);
  119. CString k("rn");
  120. content.Replace(k,"<br>" );
  121. body=Header+content+tail;
  122. tempFile.Write(body,body.GetLength() ); 
  123. tempFile.Close();
  124. EndWaitCursor();
  125. return filename;
  126. }
  127. BOOL CContainerView::IsFileExist(CString strFileName)
  128. {
  129. CFileStatus sta; 
  130. CFile tempFile;
  131. BOOL IsExist=tempFile.GetStatus(strFileName,sta);
  132. return IsExist;
  133. }