Source code of Windows XP (NT5)
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.

162 lines
4.8 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 1999
  5. *
  6. * File: msgview.h
  7. *
  8. * Contents: Interface file for CMessageView
  9. *
  10. * History: 28-Apr-99 jeffro Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #ifndef __MESSAGEVIEW_H_
  14. #define __MESSAGEVIEW_H_
  15. #include "tstring.h"
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CMessageView
  18. class ATL_NO_VTABLE CMessageView :
  19. public CComObjectRootEx<CComSingleThreadModel>,
  20. public CComCoClass<CMessageView, &CLSID_MessageView>,
  21. public CComControl<CMessageView>,
  22. public IMessageView,
  23. public IPersistStreamInitImpl<CMessageView>,
  24. public IOleControlImpl<CMessageView>,
  25. public IOleObjectImpl<CMessageView>,
  26. public IOleInPlaceActiveObjectImpl<CMessageView>,
  27. public IViewObjectExImpl<CMessageView>,
  28. public IOleInPlaceObjectWindowlessImpl<CMessageView>
  29. {
  30. public:
  31. CMessageView();
  32. ~CMessageView();
  33. DECLARE_NOT_AGGREGATABLE(CMessageView)
  34. DECLARE_MMC_OBJECT_REGISTRATION (
  35. g_szMmcndmgrDll, // implementing DLL
  36. CLSID_MessageView, // CLSID
  37. _T("MessageView Class"), // class name
  38. _T("MessageView.MessageView.1"), // ProgID
  39. _T("MessageView.MessageView")) // version-independent ProgID
  40. BEGIN_COM_MAP(CMessageView)
  41. COM_INTERFACE_ENTRY(IMessageView)
  42. COM_INTERFACE_ENTRY_IMPL(IViewObjectEx)
  43. COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject2, IViewObjectEx)
  44. COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject, IViewObjectEx)
  45. COM_INTERFACE_ENTRY_IMPL(IOleInPlaceObjectWindowless)
  46. COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleInPlaceObject, IOleInPlaceObjectWindowless)
  47. COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleWindow, IOleInPlaceObjectWindowless)
  48. COM_INTERFACE_ENTRY_IMPL(IOleInPlaceActiveObject)
  49. COM_INTERFACE_ENTRY_IMPL(IOleControl)
  50. COM_INTERFACE_ENTRY_IMPL(IOleObject)
  51. COM_INTERFACE_ENTRY_IMPL(IPersistStreamInit)
  52. END_COM_MAP()
  53. BEGIN_PROPERTY_MAP(CMessageView)
  54. // Example entries
  55. // PROP_ENTRY("Property Description", dispid, clsid)
  56. // PROP_PAGE(CLSID_StockColorPage)
  57. END_PROPERTY_MAP()
  58. BEGIN_MSG_MAP(CMessageView)
  59. MESSAGE_HANDLER (WM_CREATE, OnCreate)
  60. MESSAGE_HANDLER (WM_DESTROY, OnDestroy)
  61. MESSAGE_HANDLER (WM_SIZE, OnSize)
  62. MESSAGE_HANDLER (WM_SETTINGCHANGE, OnSettingChange)
  63. MESSAGE_HANDLER (WM_KEYDOWN, OnKeyDown)
  64. MESSAGE_HANDLER (WM_VSCROLL, OnVScroll)
  65. MESSAGE_HANDLER (WM_MOUSEWHEEL, OnMouseWheel)
  66. CHAIN_MSG_MAP (CComControl<CMessageView>)
  67. END_MSG_MAP()
  68. #define MESSAGE_HANDLER_FUNC(func) LRESULT (func)(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  69. MESSAGE_HANDLER_FUNC (OnCreate);
  70. MESSAGE_HANDLER_FUNC (OnDestroy);
  71. MESSAGE_HANDLER_FUNC (OnSize);
  72. MESSAGE_HANDLER_FUNC (OnSettingChange);
  73. MESSAGE_HANDLER_FUNC (OnKeyDown);
  74. MESSAGE_HANDLER_FUNC (OnVScroll);
  75. MESSAGE_HANDLER_FUNC (OnMouseWheel);
  76. DECLARE_WND_CLASS_EX(NULL, CS_HREDRAW, COLOR_WINDOW);
  77. // IViewObjectEx
  78. STDMETHOD(GetViewStatus)(DWORD* pdwStatus)
  79. {
  80. ATLTRACE(_T("IViewObjectExImpl::GetViewStatus\n"));
  81. *pdwStatus = VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE;
  82. return S_OK;
  83. }
  84. // IMessageView
  85. STDMETHOD(SetTitleText)(LPCOLESTR pszTitleText);
  86. STDMETHOD(SetBodyText)(LPCOLESTR pszBodyText);
  87. STDMETHOD(SetIcon)(IconIdentifier id);
  88. STDMETHOD(Clear)();
  89. public:
  90. HRESULT OnDraw(ATL_DRAWINFO& di);
  91. private:
  92. void RecalcLayout();
  93. void RecalcIconLayout();
  94. void RecalcTitleLayout();
  95. void RecalcBodyLayout();
  96. void UpdateSystemMetrics();
  97. struct TextElement;
  98. void DrawTextElement (HDC hdc, TextElement& te, DWORD dwFlags = 0);
  99. int CalcTextElementHeight (const TextElement& te, int cx);
  100. HRESULT SetTextElement (TextElement& te, LPCOLESTR pszNewText);
  101. void CreateFonts ();
  102. void DeleteFonts ();
  103. void VertScroll (int nScrollCmd, int nScrollPos, int nRepeat);
  104. void ScrollToPosition (int yScroll);
  105. void UpdateScrollSizes ();
  106. int GetOverallHeight() const
  107. { return (m_TextElement[Body].rect.bottom + m_sizeMargin.cy); }
  108. private:
  109. enum { Title, Body, ElementCount };
  110. struct TextElement
  111. {
  112. TextElement() : rect (0,0,0,0) {}
  113. tstring str;
  114. WTL::CFont font;
  115. WTL::CRect rect;
  116. };
  117. TextElement m_TextElement[ElementCount];
  118. HICON m_hIcon;
  119. WTL::CRect m_rectIcon;
  120. // for scrolling
  121. int m_yScroll;
  122. int m_yScrollMax;
  123. int m_yScrollMin;
  124. int m_cyPage;
  125. int m_cyLine;
  126. int m_nAccumulatedScrollDelta; // for WM_MOUSEWHEEL processing
  127. WTL::CSize m_sizeWindow;
  128. WTL::CSize m_sizeIcon;
  129. WTL::CSize m_sizeMargin;
  130. };
  131. #endif //__MESSAGEVIEW_H_