using System; using System.Drawing; using System.Runtime.InteropServices; using Vanara.InteropServices; using static Vanara.PInvoke.User32; namespace Vanara.PInvoke { public static partial class ComCtl32 { public const int TTN_FIRST = -520; /// Specify the icon to be displayed. [PInvokeData("Commctrl.h", MSDNShortId = "bb760414")] public enum ToolTipIcon { /// No icon. TTI_NONE = 0, /// Info icon. TTI_INFO = 1, /// Warning icon TTI_WARNING = 2, /// Error Icon TTI_ERROR = 3, /// Large error Icon TTI_INFO_LARGE = 4, /// Large error Icon TTI_WARNING_LARGE = 5, /// Large error Icon TTI_ERROR_LARGE = 6, } /// Flags that control the tooltip display. [PInvokeData("Commctrl.h", MSDNShortId = "bb760256")] [Flags] public enum ToolTipInfoFlags : uint { /// Indicates that the uId member is the window handle to the tool. If this flag is not set, uId is the tool's identifier. TTF_IDISHWND = 0x0001, /// Centers the tooltip window below the tool specified by the uId member. TTF_CENTERTIP = 0x0002, /// Indicates that the tooltip text will be displayed in the opposite direction to the text in the parent window. TTF_RTLREADING = 0x0004, /// /// Indicates that the tooltip control should subclass the tool's window to intercept messages, such as WM_MOUSEMOVE. If this /// flag is not set, you must use the TTM_RELAYEVENT message to forward messages to the tooltip control. For a list of messages /// that a tooltip control processes, see TTM_RELAYEVENT. /// TTF_SUBCLASS = 0x0010, /// /// Positions the tooltip window next to the tool to which it corresponds and moves the window according to coordinates supplied /// by the TTM_TRACKPOSITION messages. You must activate this type of tool using the TTM_TRACKACTIVATE message. /// TTF_TRACK = 0x0020, /// /// Positions the tooltip window at the same coordinates provided by TTM_TRACKPOSITION. This flag must be used with the TTF_TRACK flag. /// TTF_ABSOLUTE = 0x0080, /// /// Causes the tooltip control to forward mouse event messages to the parent window. This is limited to mouse events that occur /// within the bounds of the tooltip window. /// TTF_TRANSPARENT = 0x0100, /// /// Version 6.0 and later. Indicates that links in the tooltip text should be parsed. /// /// Note that Comctl32.dll version 6 is not redistributable but it is included in Windows or later. To use Comctl32.dll version /// 6, specify it in a manifest. For more information on manifests, see Enabling Visual Styles. /// /// TTF_PARSELINKS = 0x1000, /// The TTF di setitem TTF_DI_SETITEM = 0x8000, // valid only on the TTN_NEEDTEXT callback } [PInvokeData("Commctrl.h", MSDNShortId = "bb760542")] public enum ToolTipMessage { TTM_ACTIVATE = WindowMessage.WM_USER + 1, TTM_SETDELAYTIME = WindowMessage.WM_USER + 3, TTM_ADDTOOL = WindowMessage.WM_USER + 50, TTM_DELTOOL = WindowMessage.WM_USER + 51, TTM_NEWTOOLRECT = WindowMessage.WM_USER + 52, TTM_RELAYEVENT = WindowMessage.WM_USER + 7, // Win7: wParam = GetMessageExtraInfo() when relaying WM_MOUSEMOVE TTM_GETTOOLINFO = WindowMessage.WM_USER + 53, TTM_SETTOOLINFO = WindowMessage.WM_USER + 54, TTM_HITTEST = WindowMessage.WM_USER + 55, TTM_GETTEXT = WindowMessage.WM_USER + 56, TTM_UPDATETIPTEXT = WindowMessage.WM_USER + 57, TTM_GETTOOLCOUNT = WindowMessage.WM_USER + 13, TTM_ENUMTOOLS = WindowMessage.WM_USER + 58, TTM_GETCURRENTTOOL = WindowMessage.WM_USER + 59, TTM_WINDOWFROMPOINT = WindowMessage.WM_USER + 16, TTM_TRACKACTIVATE = WindowMessage.WM_USER + 17, // wParam = TRUE/FALSE start end lparam = LPTOOLINFO TTM_TRACKPOSITION = WindowMessage.WM_USER + 18, // lParam = dwPos TTM_SETTIPBKCOLOR = WindowMessage.WM_USER + 19, TTM_SETTIPTEXTCOLOR = WindowMessage.WM_USER + 20, TTM_GETDELAYTIME = WindowMessage.WM_USER + 21, TTM_GETTIPBKCOLOR = WindowMessage.WM_USER + 22, TTM_GETTIPTEXTCOLOR = WindowMessage.WM_USER + 23, TTM_SETMAXTIPWIDTH = WindowMessage.WM_USER + 24, TTM_GETMAXTIPWIDTH = WindowMessage.WM_USER + 25, TTM_SETMARGIN = WindowMessage.WM_USER + 26, // lParam = lprc TTM_GETMARGIN = WindowMessage.WM_USER + 27, // lParam = lprc TTM_POP = WindowMessage.WM_USER + 28, TTM_UPDATE = WindowMessage.WM_USER + 29, TTM_GETBUBBLESIZE = WindowMessage.WM_USER + 30, TTM_ADJUSTRECT = WindowMessage.WM_USER + 31, TTM_SETTITLE = WindowMessage.WM_USER + 33, // wParam = TTI_*, lParam = wchar* szTitle TTM_POPUP = WindowMessage.WM_USER + 34, TTM_GETTITLE = WindowMessage.WM_USER + 35, // wParam = 0, lParam = TTGETTITLE* TTM_SETWINDOWTHEME = CommonControlMessage.CCM_SETWINDOWTHEME } [PInvokeData("Commctrl.h", MSDNShortId = "ff486070")] public enum ToolTipNotification { /// /// Sent by a tooltip control to retrieve information needed to display a tooltip window. This notification code is sent in the /// form of a WM_NOTIFY message. /// TTN_GETDISPINFO = TTN_FIRST - 10, /// /// Notifies the owner window that a tooltip control is about to be displayed. This notification code is sent in the form of a /// WM_NOTIFY message. /// TTN_SHOW = TTN_FIRST - 1, /// /// Notifies the owner window that a tooltip is about to be hidden. This notification code is sent in the form of a WM_NOTIFY message. /// TTN_POP = TTN_FIRST - 2, /// /// Sent when a text link inside a balloon tooltip is clicked. This notification code is sent in the form of a WM_NOTIFY message. /// TTN_LINKCLICK = TTN_FIRST - 3, /// /// Sent by a tooltip control to retrieve information needed to display a tooltip window. This notification code is identical to /// TTN_GETDISPINFO. This notification code is sent in the form of a WM_NOTIFY message. /// TTN_NEEDTEXT = TTN_GETDISPINFO, } /// /// Contains information used in handling the TTN_GETDISPINFO notification code. This structure supersedes the TOOLTIPTEXT structure. /// [PInvokeData("Commctrl.h", MSDNShortId = "bb760258")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct NMTTDISPINFO { /// NMHDR structure that contains additional information about the notification. public NMHDR hdr; /// /// Pointer to a null-terminated string that will be displayed as the tooltip text. If hinst specifies an instance handle, this /// member must be the identifier of a string resource. /// public string lpszText; /// /// Buffer that receives the tooltip text. An application can copy the text to this buffer instead of specifying a string address /// or string resource. For tooltip text that exceeds 80 TCHARs, see comments in the remarks section of this document. /// [MarshalAs(UnmanagedType.LPTStr, SizeConst = 80)] public string szText; /// /// Handle to the instance that contains a string resource to be used as the tooltip text. If lpszText is the address of the /// tooltip text string, this member must be NULL. /// public HINSTANCE hinst; /// /// Flags that indicates how to interpret the idFrom member of the included NMHDR structure. /// /// /// Value /// Meaning /// /// /// TTF_IDISHWND /// If this flag is set, idFrom is the tool's handle. Otherwise, it is the tool's identifier. /// /// /// TTF_RTLREADING /// /// Windows can be mirrored to display languages such as Hebrew or Arabic that read right-to-left (RTL). Normally, tooltip text /// is read in same direction as the text in its parent window. To have a tooltip read in the opposite direction from its parent /// window, add the TTF_RTLREADING flag to the uFlags member when processing the notification. /// /// /// /// TTF_DI_SETITEM /// /// Version 4.70. If you add this flag to uFlags while processing the notification, the tooltip control will retain the supplied /// information and not request it again. /// /// /// /// public ToolTipInfoFlags uFlags; /// Version 4.70. Application-defined data associated with the tool. public IntPtr lParam; } /// The TOOLINFO structure contains information about a tool in a tooltip control. [PInvokeData("Commctrl.h", MSDNShortId = "bb760256")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct TOOLINFO { /// Size of this structure, in bytes. This member must be specified. public uint cbSize; /// Flags that control the tooltip display. This member can be a combination of the following values: public ToolTipInfoFlags uFlags; /// /// Handle to the window that contains the tool. If lpszText includes the LPSTR_TEXTCALLBACK value, this member identifies the /// window that receives the TTN_GETDISPINFO notification codes. /// public HWND hwnd; /// /// Application-defined identifier of the tool. If uFlags includes the TTF_IDISHWND flag, uId must specify the window handle to /// the tool. /// public IntPtr uId; /// /// The bounding rectangle coordinates of the tool. The coordinates are relative to the upper-left corner of the client area of /// the window identified by hwnd. If uFlags includes the TTF_IDISHWND flag, this member is ignored. /// public RECT rect; /// /// Handle to the instance that contains the string resource for the tool. If lpszText specifies the identifier of a string /// resource, this member is used. /// public HINSTANCE hinst; /// /// Pointer to the buffer that contains the text for the tool, or identifier of the string resource that contains the text. This /// member is sometimes used to return values. If you need to examine the returned value, must point to a valid buffer of /// sufficient size. Otherwise, it can be set to NULL. If lpszText is set to LPSTR_TEXTCALLBACK, the control sends the /// TTN_GETDISPINFO notification code to the owner window to retrieve the text. /// public StrPtrAuto lpszText; /// Version 4.70 and later. A 32-bit application-defined value that is associated with the tool. public IntPtr lParam; /// Reserved. Must be set to NULL. public IntPtr lpReserved; } /// Provides information about the title of a tooltip control. [PInvokeData("Commctrl.h", MSDNShortId = "bb760260")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct TTGETTITLE { /// DWORD that specifies size of structure. Set to sizeof(TTGETTITLE). public uint dwSize; /// UINT that specifies the tooltip icon. public ToolTipIcon uTitleBitmap; /// UINT that specifies the number of characters in the title. public uint cch; /// Pointer to a wide character string that contains the title. public StrPtrUni pszTitle; } /// /// Contains information that a tooltip control uses to determine whether a point is in the bounding rectangle of the specified tool. /// If the point is in the rectangle, the structure receives information about the tool. /// [PInvokeData("Commctrl.h", MSDNShortId = "bb760262")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct TTHITTESTINFO { /// Handle to the tool or window with the specified tool. public HWND hwnd; /// Client coordinates of the point to test. public Point pt; /// /// TOOLINFO structure. If the point specified by pt is in the tool specified by hwnd, this structure receives information about /// the tool. The cbSize member of this structure must be filled in before sending this message. /// public TOOLINFO ti; } } }