HtmlCtrl.cpp
Upload User: fhtm20
Upload Date: 2021-02-11
Package Size: 3405k
Code Size: 2k
Development Platform:

Visual C++

  1. //////////////////////////////////////////////////////////////////////////////
  2. //功能:对话框内部显示HTML网页
  3. //作者:依星(airen3339@163.com)
  4. //日期:2005.12
  5. /////////////////////////////////////////////////////////////////////////////
  6. #include "StdAfx.h"
  7. #include "HtmlCtrl.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. IMPLEMENT_DYNAMIC(CHtmlCtrl, CHtmlView)
  14. BEGIN_MESSAGE_MAP(CHtmlCtrl, CHtmlView)
  15. ON_WM_DESTROY()
  16. ON_WM_MOUSEACTIVATE()
  17. END_MESSAGE_MAP()
  18. //////////////////////////////////////////////////////////////////////////
  19. // Create control in same position as an existing static control with
  20. // the same ID (could be any kind of control, really)
  21. //
  22. BOOL CHtmlCtrl::CreateFromStatic(UINT nID, CWnd* pParent)
  23. {
  24. CStatic wndStatic;
  25. if (!wndStatic.SubclassDlgItem(nID, pParent))
  26. return FALSE;
  27. // Get static control rect, convert to parent's client coords.
  28. CRect rc;
  29. wndStatic.GetWindowRect(&rc);
  30. pParent->ScreenToClient(&rc);
  31. wndStatic.DestroyWindow();
  32. // create HTML control (CHtmlView)
  33. return Create(NULL,  // class name
  34. NULL,  // title
  35. (WS_CHILD | WS_VISIBLE ),  // style
  36. rc,  // rectangle
  37. pParent,  // parent
  38. nID,  // control ID
  39. NULL);                                     // frame/doc context not used
  40. }
  41. ////////////////
  42. // Override to avoid CView stuff that assumes a frame.
  43. //
  44. void CHtmlCtrl::OnDestroy()
  45. {
  46. // This is probably unecessary since ~CHtmlView does it, but
  47. // safer to mimic CHtmlView::OnDestroy.
  48. if (m_pBrowserApp) {
  49. m_pBrowserApp->Release();
  50. m_pBrowserApp = NULL;
  51. }
  52. CWnd::OnDestroy(); // bypass CView doc/frame stuff
  53. }
  54. ////////////////
  55. // Override to avoid CView stuff that assumes a frame.
  56. //
  57. int CHtmlCtrl::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT msg)
  58. {
  59. // bypass CView doc/frame stuff
  60. return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, msg);
  61. }