Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.7 KiB

  1. ////////////////////////////////////////////////////////////////
  2. // Microsoft Systems Journal -- December 1999
  3. // If this code works, it was written by Paul DiLascia.
  4. // If not, I don't know who wrote it.
  5. // Compiles with Visual C++ 6.0, runs on Windows 98 and probably NT too.
  6. //
  7. #include "StdAfx.h"
  8. #include "HtmlCtrl.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. IMPLEMENT_DYNAMIC(CHtmlCtrl, CHtmlView)
  15. BEGIN_MESSAGE_MAP(CHtmlCtrl, CHtmlView)
  16. ON_WM_DESTROY()
  17. ON_WM_MOUSEACTIVATE()
  18. END_MESSAGE_MAP()
  19. //////////////////
  20. // Create control in same position as an existing static control with
  21. // the same ID (could be any kind of control, really)
  22. //
  23. BOOL CHtmlCtrl::CreateFromStatic(UINT nID, CWnd* pParent)
  24. {
  25. CStatic wndStatic;
  26. if (!wndStatic.SubclassDlgItem(nID, pParent))
  27. return FALSE;
  28. // Get static control rect, convert to parent's client coords.
  29. CRect rc;
  30. wndStatic.GetWindowRect(&rc);
  31. pParent->ScreenToClient(&rc);
  32. wndStatic.DestroyWindow();
  33. // create HTML control (CHtmlView)
  34. return Create(NULL, // class name
  35. NULL, // title
  36. (WS_CHILD | WS_VISIBLE ), // style
  37. rc, // rectangle
  38. pParent, // parent
  39. nID, // control ID
  40. NULL); // frame/doc context not used
  41. }
  42. ////////////////
  43. // Override to avoid CView stuff that assumes a frame.
  44. //
  45. void CHtmlCtrl::OnDestroy()
  46. {
  47. // This is probably unecessary since ~CHtmlView does it, but
  48. // safer to mimic CHtmlView::OnDestroy.
  49. if (m_pBrowserApp) {
  50. m_pBrowserApp->Release();
  51. m_pBrowserApp = NULL;
  52. }
  53. CWnd::OnDestroy(); // bypass CView doc/frame stuff
  54. }
  55. ////////////////
  56. // Override to avoid CView stuff that assumes a frame.
  57. //
  58. int CHtmlCtrl::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT msg)
  59. {
  60. // bypass CView doc/frame stuff
  61. return CWnd::OnMouseActivate(pDesktopWnd, nHitTest, msg);
  62. }
  63. //////////////////
  64. // Override navigation handler to pass to "app:" links to virtual handler.
  65. // Cancels the navigation in the browser, since app: is a pseudo-protocol.
  66. //
  67. void CHtmlCtrl::OnBeforeNavigate2( LPCTSTR lpszURL,
  68. DWORD nFlags,
  69. LPCTSTR lpszTargetFrameName,
  70. CByteArray& baPostedData,
  71. LPCTSTR lpszHeaders,
  72. BOOL* pbCancel )
  73. {
  74. const char APP_PROTOCOL[] = "app:";
  75. int len = _tcslen(APP_PROTOCOL);
  76. if (_tcsnicmp(lpszURL, APP_PROTOCOL, len)==0) {
  77. OnAppCmd(lpszURL + len);
  78. *pbCancel = TRUE;
  79. }
  80. }
  81. //////////////////
  82. // Called when the browser attempts to navigate to "app:foo"
  83. // with "foo" as lpszWhere. Override to handle app commands.
  84. //
  85. void CHtmlCtrl::OnAppCmd(LPCTSTR lpszWhere)
  86. {
  87. // default: do nothing
  88. }