/** * @file XTPToolTipContext.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPTOOLTIPCONTEXT_H__) # define __XTPTOOLTIPCONTEXT_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPImageManager; class CXTPImageManagerIcon; /** @cond */ const UINT XTP_TTM_WINDOWFROMPOINT = (WM_USER + 9800); const UINT XTP_TTM_SETIMAGE = (WM_USER + 9801); # ifndef TTI_NONE # define TTI_NONE 0 # define TTI_INFO 1 # define TTI_WARNING 2 # define TTI_ERROR 3 # endif # define XTP_TTS_OFFICEFRAME 0x1000 # define XTP_TTS_NOSHADOW 0x2000 # define XTP_TTS_OFFICE2007FRAME 0x4000 # define XTP_TTS_OFFICE2013FRAME 0x8000 struct XTP_TOOLTIP_CONTEXT { LPTSTR lpszDescription; LPTSTR lpszTitle; CXTPImageManager* pImageManager; RECT rcExclude; CCmdTarget* pObject; }; struct XTP_TOOLTIP_TOOLINFO { UINT cbSize; UINT uFlags; HWND hwnd; UINT_PTR uId; RECT rect; HINSTANCE hinst; LPTSTR lpszText; }; struct XTP_TOOLTIP_TOOLINFO_EX : public XTP_TOOLTIP_TOOLINFO { XTP_TOOLTIP_CONTEXT* pToolInfo; }; /** @endcond */ /** * @brief * Enumeration used to determine styles for tooltips * * Example: *
pCommandBars->GetToolTipContext()->SetStyle(xtpToolTipBalloon);* @see * CXTPToolTipContext::SetStyle, xtpToolTipBalloon, xtpToolTipBalloon, xtpToolTipOffice */ enum XTPToolTipStyle { xtpToolTipStandard, /**< Standard tooltip window style */ xtpToolTipBalloon, /**< Balloon tooltip window style */ xtpToolTipOffice, /**< Office tooltip window style */ xtpToolTipRTF, /**< RTF tooltip window style */ xtpToolTipLuna, /**< Luna tooltip window style */ xtpToolTipResource, /**< Office 2007 window style */ xtpToolTipHTML, /**< HTML tooltip style */ xtpToolTipMarkup, /**< HTML tooltip style */ xtpToolTipOffice2013, /**< Office 2013 tooltip window style */ xtpToolTipOffice2016 = xtpToolTipOffice2013 /**< Office 2016 tooltip window style */ }; // Obsolete # define xtpToolTipOffice2007 xtpToolTipResource class CXTPToolTipContext; /** * @brief * CXTPToolTipContextToolTip is CWnd derived class, the base class for * custom tool tips. */ class _XTP_EXT_CLASS CXTPToolTipContextToolTip : public CWnd { /** @cond */ DECLARE_DYNAMIC(CXTPToolTipContextToolTip) /** @endcond */ public: /** * @brief * Constructs a CXTPToolTipContextToolTip object * @param pContext Pointer to parent tooltip context */ CXTPToolTipContextToolTip(CXTPToolTipContext* pContext); /** * @brief * Destroys a CXTPToolTipContextToolTip object, handles cleanup and deallocation */ virtual ~CXTPToolTipContextToolTip(); /** @cond */ struct TOOLITEM { CString strCaption; BOOL bAutoCaption; UINT uFlags; CRect rect; HINSTANCE hinst; HWND hwnd; UINT_PTR uId; CRect rectExclude; BOOL IsEqual(TOOLITEM* pItem) { return (pItem && hwnd == pItem->hwnd && uId == pItem->uId) || (!pItem && !hwnd); } BOOL IsEmpty() { return hwnd == 0; } void Reset() { strCaption.Empty(); uFlags = 0; hwnd = 0; uId = (UINT)-1; hinst = 0; rect.SetRectEmpty(); rectExclude.SetRectEmpty(); } void Assign(TOOLITEM* pItem) { if (pItem) *this = *pItem; else Reset(); } }; public: BOOL Create(CWnd* pParentWnd, DWORD dwStyle); public: BOOL AddTool(LPTOOLINFO lpToolInfo); void Activate(BOOL bActivate); void DelTool(LPTOOLINFO lpToolInfo); void RelayEvent(LPMSG lpMsg); /** @endcond */ protected: /** * @brief * This method is called to retrieve size of tool tip to show * @param lpToolInfo Pointer to tooltip specific information * @return * Size of new tool tip. * @see * DrawEntry */ virtual CSize GetToolSize(TOOLITEM* lpToolInfo); /** * @brief * This method is called to draw face of tool tip. * @param pDC Pointer to a valid device context * @param rc Client rectangle * @param lpToolInfo Pointer to tooltip specific information */ virtual void DrawEntry(CDC* pDC, TOOLITEM* lpToolInfo, CRect rc); /** * @brief * This method is called to draw background of tool tip. * @param pDC Pointer to a valid device context * @param rc Client rectangle * @param lpToolInfo Pointer to tooltip specific information */ virtual void DrawBackground(CDC* pDC, TOOLITEM* lpToolInfo, CRect rc); /** @cond */ protected: virtual void OnVisibleChanged(BOOL /*bVisble*/) { } BOOL IsVisible() const { return GetSafeHwnd() && IsWindowVisible(); } TOOLITEM* FindTool(); CString GetToolText(TOOLITEM* lpToolInfo); void SetVisibleTool(TOOLITEM* lpToolInfo); static LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam); void HookMouseMove(BOOL bSetupHook); void EnsureVisible(CRect& rcToolTip); int GetMaxTipWidth() const; void SetRoundRectRegion(CWnd* pWnd); /** @endcond */ protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPToolTipContextToolTip) //}}AFX_VIRTUAL //{{AFX_MSG(CXTPToolTipContextToolTip) afx_msg LRESULT OnAddTool(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnActivate(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnDelTool(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnRelayEvent(WPARAM, LPARAM lParam); afx_msg LRESULT OnSetTitle(WPARAM, LPARAM lParam); afx_msg LRESULT OnUpdateTipText(WPARAM, LPARAM lParam); afx_msg void OnPaint(); afx_msg LRESULT OnPrintClient(WPARAM wParam, LPARAM lParam); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg LRESULT OnNcHitTest(CPoint point); afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnTimer(UINT_PTR nIDEvent); afx_msg LRESULT OnWindowFromPoint(WPARAM, LPARAM); afx_msg LRESULT OnSetImage(WPARAM, LPARAM); afx_msg LRESULT OnSetDelayTime(WPARAM, LPARAM lParam); afx_msg void OnDestroy(); //}}AFX_MSG /** @endcond */ private: BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); protected: CArray
m_wndToolBox.GetToolTipContext()->ModifyToolTipStyle(TTS_NOPREFIX, 0);*/ void ModifyToolTipStyle(DWORD dwRemove, DWORD dwAdd); /** * @return * Retrieves control style * @see * ModifyToolTipStyle */ DWORD GetControlStyle() const; /** * @brief * Call this function to set the delay time for a tool tip control. The delay time is the * length of time the cursor must remain on a tool before the tool tip window appears. The * default delay time is 500 milliseconds. * @param dwDuration Flag that specifies which duration value will be retrieved. See * CToolTipCtrl::GetDelayTime for a description of the valid values. * @param iTime The specified delay time, in milliseconds. */ void SetDelayTime(DWORD dwDuration, int iTime); /** * @brief * Call this member function to remove a tooltip from the screen if a tooltip is currently * displayed. */ void CancelToolTips(); /** * @brief * Call this method to set the custom font for tooltips. * @param pFont Pointer to the font to be set. */ void SetFont(CFont* pFont); /** * @brief * Call this method to get the custom font for tooltips. * @return * A pointer to the custom font for tooltips. */ CFont* GetFont(); /** * @brief * Call this method to set custom font for tooltips * @param lpLogFont Font to be set */ void SetFontIndirect(LOGFONT* lpLogFont); /** * @brief * Call this method to set custom tooltip ctrl * @param pToolTipCtrl new tooltip to be set * * Example: *
pCommandBars->GetTooltipContext()->SetToolTipCtrl(new CMyTooltip());*/ void SetToolTipCtrl(CXTPToolTipContextToolTip* pToolTipCtrl); /** * @brief * Call this method to remove ellipsis from tip title * @param bSet TRUE to remove ellipsis from title */ void StripEllipsisFromToolTip(BOOL bSet); /** * @brief * Call this method to determine if ellipsis will be removed from tip title * @return * TRUE if ellipsis are removed from tip title */ BOOL GetStripEllipsisFromToolTip() const; /** * @brief * This method is called to create tooltip window. You can override it to create custom tool * tip derived from CXTPToolTipContextToolTip * @param pOwner Specifies the tool tip control's parent window. * @return * New tool tip window. */ virtual CWnd* CreateToolTip(CWnd* pOwner); protected: /** @cond */ virtual INT_PTR OnToolHitTest(CWnd* pWnd, CPoint point, TOOLINFO* pToolInf); public: static void AFX_CDECL FillInToolInfo(TOOLINFO* pTI, HWND hWnd, CRect rect, INT_PTR nHit, const CString& strToolTip); static void AFX_CDECL FillInToolInfo(TOOLINFO* pTI, HWND hWnd, CRect rect, INT_PTR nHit, const CString& strToolTip, const CString& strTitle, const CString& strDescription, CXTPImageManager* pImageManager = 0); void FilterToolTipMessage(CWnd* pWndHost, MSG* pMsg); void FilterToolTipMessage(CWnd* pWndHost, UINT message, WPARAM wParam, LPARAM lParam); void FilterToolTipMessageHelper(CWnd* pWndHost, MSG* pMsg, BOOL bIgnoreFlags); void RelayToolTipMessage(CWnd* pToolTip, MSG* pMsg); void SetModuleToolTipContext(); static void PASCAL FilterToolTipMessageStatic(MSG* pMsg, CWnd* pWnd); static int AFX_CDECL GetCursorHeight(); void DrawBackground(CDC* pDC, CRect rc); /** @endcond */ private: friend class CXTPToolTipContextToolTip; friend class CRichEditToolTip; friend class COffice2013ToolTip; protected: BOOL m_bShowTitleAndDescription; /**< TRUE to show title and description for tooltip. */ BOOL m_bShowImage; /**< TRUE to show images in tooltip */ BOOL m_nImageSize; /**< Size of images in tooltip */ CSize m_szVectorIconSmall; /**< Size of small vector icon */ CSize m_szVectorIconLarge; /**< Size of large vector icon */ int m_nImageBase; /**< This value will be added to tool identifier to retrieve image for tip. */ BOOL m_bImageDPIScaling; /**< Enables DPI scaling of images. */ XTPToolTipStyle m_toolStyle; /**< Tooltip style */ DWORD m_dwComCtlVersion; /**< CommCtrl.dll version */ int m_nIconTitle; /**< Icon title for extended tooltip */ int m_nMaxTipWidth; /**< Maximum width of tooltip window */ DWORD m_dwStyle; /**< Tooltip style */ CRect m_rcMargin; /**< Margin or "padding" placed around the tooltip text. The sides of the CRect indicate the amount of padding for the left, top, bottom, and right sides of the tooltip window. */ int m_nDelayInitial; /**< The length of time the pointer must remain stationary within a tool's bounding rectangle before the tool tip window appears. */ int m_nDelayReshow; /**< The length of time it takes for subsequent tool tip windows to appear as the pointer moves from one tool to another. */ int m_nDelayAutoPop; /**< the length of time a tooltip window remains visible if the pointer is stationary within a tool's bounding rectangle. */ CWnd* m_pToolTip; /**< Owned Tooltip window */ XTP_TOOLTIP_TOOLINFO_EX m_lastInfo; /**< Last tooltip info. */ static CXTPToolTipContext* m_pModuleContext; /**< Tooltip for current module */ COLORREF m_clrTipBkColor; /**< Background color in a tooltip window */ COLORREF m_clrTipTextColor; /**< Text color in a tooltip window. */ BOOL m_bStripEllipsisFromToolTip; /**< TRUE to remove ellipses from tip caption (defailt is TRUE) */ CXTPFont m_xtpFont; /**< Font of the tool tip. */ CXTPFont m_xtpFontTitle; /**< Font of the tool tip title. */ XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_fnt, m_xtpFont, GetFontHandle); XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_fntTitle, m_xtpFontTitle, GetTitleFontHandle); private: BOOL m_bImageDPIScalingModified; # ifdef _XTP_ACTIVEX /** @cond */ public: DECLARE_INTERFACE_MAP() DECLARE_DISPATCH_MAP() DECLARE_OLETYPELIB_EX(CXTPToolTipContext); afx_msg void OleSetMargin(long left, long top, long right, long bottom); LPFONTDISP OleGetFont(); void OleSetFont(LPFONTDISP pFontDisp); void OleShowImage(BOOL bShowImage, int nImageBase); void OleSetVectorIconSize(long cx, long cy); DECLARE_PROPERTY(ShowOfficeBorder, BOOL); DECLARE_PROPERTY(ShowShadow, BOOL); /** @endcond */ # endif }; /** @cond */ AFX_INLINE CRect CXTPToolTipContext::GetMargin() const { return m_rcMargin; } AFX_INLINE BOOL CXTPToolTipContextToolTip::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext); } AFX_INLINE DWORD CXTPToolTipContext::GetControlStyle() const { return m_dwStyle; } AFX_INLINE BOOL CXTPToolTipContext::IsShowTitleAndDescription() const { return m_bShowTitleAndDescription; } AFX_INLINE CFont* CXTPToolTipContext::GetFont() { return &m_xtpFont; } AFX_INLINE void CXTPToolTipContext::StripEllipsisFromToolTip(BOOL bSet) { m_bStripEllipsisFromToolTip = bSet; } AFX_INLINE BOOL CXTPToolTipContext::GetStripEllipsisFromToolTip() const { return m_bStripEllipsisFromToolTip; } AFX_INLINE BOOL CXTPToolTipContext::IsImageDPIScalingEnabled() const { return IsDpiBitmapScalingEnabled(); } AFX_INLINE void CXTPToolTipContext::EnableImageDPIScaling(BOOL bScale) { EnableDpiBitmapScaling(bScale); } /** @endcond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPTOOLTIPCONTEXT_H__) /** @endcond */