MSDN对ToolTip的介绍

本文详细介绍了工具提示控件的功能及使用方法,包括自动显示、不同类型工具提示的创建方式及其编程元素,例如消息、结构、常量等。此外还提供了有关自定义绘制、通知和样式设置的具体信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Tooltip

This section contains information about the programming elements used with tooltip controls.

本节包含工具提示控件使用的编程元素的信息。

Overviews

Topic

Contents

About Tooltip Controls

Tooltips appear automatically, or pop up, when the user pauses the mouse pointer over a tool or some other UI element.

当用户在工具或其它一些UI元素暂停鼠标指针移到,Tooltips会自动出现,或者弹出。

Using Tooltip Controls

This section contains examples that demonstrate how to create different types of tooltips.

本节包含了一些例子,演示如何创建不同类型的Tooltips。

 

Messages

Topic

Contents

TTM_ACTIVATE

Activates or deactivates a tooltip control.

激活或停用的Tooltips控件。

TTM_ADDTOOL

Registers a tool with a tooltip control.

注册一个带Tooltips控件的工具。

TTM_ADJUSTRECT

Calculates a tooltip control's text display rectangle from its window rectangle, or the tooltip window rectangle needed to display a specified text display rectangle.

计算一个tooltip控件其窗口矩形的文本显示矩形,或需要显示指定的文本显示矩形的tooltip窗口的矩形。

TTM_DELTOOL

Removes a tool from a tooltip control.

从tooltip控件移除一个工具。

TTM_ENUMTOOLS

Retrieves the information that a tooltip control maintains about the current tool—that is, the tool for which the tooltip is currently displaying text.

获取tooltip控件维持的当前工具信息,也就是当前tooltip正在显示文本的工具的信息。

TTM_GETBUBBLESIZE

Returns the width and height of a tooltip control.

返回tooltip控件的宽度和高度

TTM_GETCURRENTTOOL

Retrieves the information for the current tool in a tooltip control.

获取tooltip控件里当前工具的信息

TTM_GETDELAYTIME

Retrieves the initial, pop-up, and reshow durations currently set for a tooltip control.

获取当前设置一个tooltip控件初始化,弹出,重新显示的持续时间。

TTM_GETMARGIN

Retrieves the top, left, bottom, and right margins set for a tooltip window. A margin is the distance, in pixels, between the tooltip window border and the text contained within the tooltip window.

获取一个tooltip窗口的顶部,左侧,底部和右侧边距设置。边距的距离,以像素为单位,在tooltip窗口边框和tooltip窗口内包含的文本之间。

TTM_GETMAXTIPWIDTH

Retrieves the maximum width for a tooltip window.

获取一个tooltip窗口的最大宽度。

TTM_GETTEXT

Retrieves the information a tooltip control maintains about a tool.

获取一个tooltip控件维持的一个工具的信息。

TTM_GETTIPBKCOLOR

Retrieves the background color in a tooltip window.

获取一个tooltip窗口的背景颜色。

TTM_GETTIPTEXTCOLOR

Retrieves the text color in a tooltip window.

获取一个tooltip窗口的文本颜色。

TTM_GETTITLE

Retrieve information concerning the title of a tooltip control.

获取一个tooltip控件的标题信息。

TTM_GETTOOLCOUNT

Retrieves a count of the tools maintained by a tooltip control.

获取一个tooltip控件所维持的工具计数。

TTM_GETTOOLINFO

Retrieves the information that a tooltip control maintains about a tool.

获取一个tooltip控件维持的关于一个工具的信息。

TTM_HITTEST

Tests a point to determine whether it is within the bounding rectangle of the specified tool and, if it is, retrieves information about the tool.

测试一个点来确定是否它是在指定的工具的矩形边界内,如果是,获取有关这个工具的信息。

TTM_NEWTOOLRECT

Sets a new bounding rectangle for a tool.

设置一个工具新的矩形边界。

TTM_POP

Removes a displayed tooltip window from view.

从视图移除一个显示的tooltip窗口。

TTM_POPUP

Causes the tooltip to display at the coordinates of the last mouse message.

使tooltip显示在最后鼠标消息的坐标。

TTM_RELAYEVENT

Passes a mouse message to a tooltip control for processing.

通过鼠标消息进行处理的tooltip控件。

TTM_SETDELAYTIME

Sets the initial, pop-up, and reshow durations for a tooltip control.

设置一个tooltip控件的初始化,弹出和重新显示持续时间。

TTM_SETMARGIN

Sets the top, left, bottom, and right margins for a tooltip window. A margin is the distance, in pixels, between the tooltip window border and the text contained within the tooltip window.

设置一个tooltip窗口的顶部,左侧,底部和右侧边距设置。边距的距离,以像素为单位,在tooltip窗口边框和tooltip窗口内包含的文本之间。

TTM_SETMAXTIPWIDTH

Sets the maximum width for a tooltip window.

设置一个tooltip窗口的最大宽度。

TTM_SETTIPBKCOLOR

Sets the background color in a tooltip window.

设置一个tooltip窗口的背景颜色。

TTM_SETTIPTEXTCOLOR

Sets the text color in a tooltip window.

设置一个tooltip窗口的文本颜色。

TTM_SETTITLE

Adds a standard icon and title string to a tooltip.

设置一个tooltip控件的标题信息。

TTM_SETTOOLINFO

Sets the information that a tooltip control maintains for a tool.

设置一个tooltip控件维持的关于一个工具的信息。

TTM_SETWINDOWTHEME

Sets the visual style of a tooltip control.

设置一个tooltip控件的视觉风格。

TTM_TRACKACTIVATE

Activates or deactivates a tracking tooltip.

激活或停用一个跟踪tooltip。

TTM_TRACKPOSITION

Sets the position of a tracking tooltip.

设置一个跟踪tooltip的位置。

TTM_UPDATE

Forces the current tooltip to be redrawn.

强制当前tooltip被重绘。

TTM_UPDATETIPTEXT

Sets the tooltip text for a tool.

设置一个工具的tooltip文本。

TTM_WINDOWFROMPOINT

Allows a subclass procedure to cause a tooltip to display text for a window other than the one beneath the mouse cursor.

允许一个子类的过程引起一个tooltip为一个鼠标光标下方以外的窗口显示文本。

 

Notifications

Topic

Contents

NM_CUSTOMDRAW (Tooltip)

Sent by a tooltip control to notify its parent windows about drawing operations. This notification code is sent in the form of aWM_NOTIFY message.

一个tooltip控件发送通知它的父窗口绘制操作。此通知代码是在一个WM_NOTIFY消息的形式发送。

TTN_GETDISPINFO

Sent by a tooltip control to retrieve information needed to display a tooltip window. This notification code is sent in the form of aWM_NOTIFY message.

一个tooltip控件发送去获取需要显示一个tooltip窗口的信息。此通知代码是在一个WM_NOTIFY消息的形式发送。

TTN_LINKCLICK

Sent when a text link inside a balloon tooltip is clicked.

当气泡tooltip内的文本链接被点击时发送。

TTN_NEEDTEXT

Sent by a tooltip control to retrieve information needed to display a tooltip window. This notification is identical toTTN_GETDISPINFO. This notification code is sent in the form of aWM_NOTIFY message.

一个tooltip控件发送去获取需要显示一个提示窗口的信息。这个通知是相同TTN_GETDISPINFO的。此通知代码是在一个WM_NOTIFY消息的形式发送。

TTN_POP

Notifies the owner window that a tooltip is about to be hidden. This notification code is sent in the form of aWM_NOTIFY message.

通知所有者窗口,一个tooltip将被隐藏。此通知代码是在一个WM_NOTIFY消息的形式发送。

TTN_SHOW

Notifies the owner window that a tooltip control is about to be displayed. This notification code is sent in the form of aWM_NOTIFY message.

通知所有者窗口将要显示的tooltip控件。此通知代码是在一个WM_NOTIFY消息的形式发送。

 

Structures

Topic

Contents

NMTTCUSTOMDRAW

Contains information specific to an NM_CUSTOMDRAW notification code sent by a tooltip control.

包含一个tooltip控件发送NM_CUSTOMDRAW通知代码信息。

NMTTDISPINFO

Contains information used in handling the TTN_GETDISPINFO notification code. This structure supersedes the TOOLTIPTEXT structure.

包含用于处理TTN_GETDISPINFO通知代码的信息。这种结构取代的ToolTipText结构。

TOOLINFO

The TOOLINFO structure contains information about a tool in a tooltip control.

TOOLINFO结构包含一个tooltip控件的工具的信息。

TTGETTITLE

Provides information about the title of a tooltip control.

提供一个tooltip控件的标题信息。

TTHITTESTINFO

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.

包含一个tooltip控件使用,以确定一个点是否在指定的工具的边界矩形的信息。如果点在矩形内,结构收到有关该工具的信息。

 

Constants

Topic

Contents

Tooltip Styles

This section lists the control styles used with tooltip controls.

本节列出了tooltip控件使用的控件样式。


Tooltip Styles

This section lists the control styles used with tooltip controls.

本节列出了tooltip控件使用的控件样式。

Constant

Description

TTS_ALWAYSTIP

Indicates that the tooltip control appears when the cursor is on a tool, even if the tooltip control's owner window is inactive. Without this style, the tooltip appears only when the tool's owner window is active.

指示当光标在工具上,tooltip控件出现,即使tooltip控件的所有者窗口处于非活动状态。没有这种风格,只有当工具的所有者窗口活动时,才出现tooltip控件。

TTS_BALLOON

Version 5.80. Indicates that the tooltip control has the appearance of a cartoon "balloon," with rounded corners and a stem pointing to the item.

指示tooltip控件的卡通“气球”外观,带圆角和一个指向该项目的箭头。

TTS_CLOSE

Displays a Close button on the tooltip. Valid only when the tooltip has the TTS_BALLOON style and a title; seeTTM_SETTITLE.

显示关闭按钮的tooltip。仅当工具提示TTS_BALLOON风格和标题;见TTM_SETTITLE。

TTS_NOANIMATE

Version 5.80. Disables sliding tooltip animation on Windows 98 and Windows 2000 systems. This style is ignored on earlier systems.

在Windows 98和Windows 2000系统的tooltip动画禁用滑动。这种风格被早期的系统忽略。

TTS_NOFADE

Version 5.80. Disables fading tooltip animation on Windows 2000 systems. This style is ignored on earlier Windows NT systems, and on Windows 95 and Windows 98.

禁用Windows 2000系统上的tooltip淡入淡出动画。这种风格被早期版本的Windows NT系统、Windows 95和Windows98忽略。

TTS_NOPREFIX

Prevents the system from stripping ampersand characters from a string or terminating a string at a tab character. Without this style, the system automatically strips ampersand characters and terminates a string at the first tab character. This allows an application to use the same string as both a menu item and as text in a tooltip control.

防止系统将&符号从一个字符串去除,或终止于一个制表符的字符串。没有这种风格,系统会自动去除&符号,并且终止于第一个制表符的字符串。这允许应用程序使用同一个字符串作为一个菜单项和一个tooltip控件的文本。

TTS_USEVISUALSTYLE

Uses themed hyperlinks. The theme will define the styles for any links in the tooltip. This style always requires TTF_PARSELINKS to be set.

使用主题的超链接。主题将在tooltip中为任何链接定义风格。这种风格总是需要设置TTF_PARSELINKS。

Remarks

A tooltip control always has the WS_POPUP and WS_EX_TOOLWINDOW window styles, regardless of whether you specify them when creating the control.

一个tooltip控件始终有WS_POPUP和WS_EX_TOOLWINDOW窗口样式,不管你创建控件时是否指定。


NMTTCUSTOMDRAW Structure

typedef struct tagNMTTCUSTOMDRAW { 
  NMCUSTOMDRAW nmcd;        //包含自定义绘制的信息 
  UINT         uDrawFlags;    //指定ToolTip文本显示时,将如何被格式化 
} NMTTCUSTOMDRAW, *LPNMTTCUSTOMDRAW; 
NMTTDISPINFO Structure

typedef struct { 
  NMHDR     hdr;    //NMHDR结构,它包含有关通知的其他信息 
  LPTSTR    lpszText;    //作为ToolTip文本显示的一个空终止符字符串指针 
  TCHAR     szText;    //缓冲区接收ToolTip文本 
  HINSTANCE hinst;    //实例,此实例包含ToolTip文本使用的字符串资源 
  UINT      uFlags;    //标志,指示如何解释包含的NMHDR结构的idFrom成员 
#if (_WIN32_IE >= 0x0300
  LPARAM    lParam;    //应用程序定义的数据与该工具关联 
#endif  
} NMTTDISPINFO, *LPNMTTDISPINFO; 
TOOLINFO Structure

typedef struct { 
  UINT      cbSize;    //这个结构的大小,以字节为单位。这名成员必须指定 
  UINT      uFlags;    //控制tooltip显示的标志 
  HWND      hwnd;    //包含工具的窗口的句柄 
  UINT_PTR  uId;    //应用程序定义这个工具的标识符 
  RECT      rect;    //工具的矩形边界坐标 
  HINSTANCE hinst;    //实例,此实例包含ToolTip文本使用的字符串资源 
  LPTSTR    lpszText;    //缓冲区的指针,包含工具显示文本,或包含文本的字符串资源标识符 
#if (_WIN32_IE >= 0x0300
  LPARAM    lParam;    //Version 4.70及以上。一个32位应用程序定义的值,与该工具关联 
#endif  
#if (_WIN32_WINNT >= Ox0501) 
  void      *lpReserved;//Windows XP and later. 保留。必须设置为NULL 
#endif  
} TOOLINFO, *PTOOLINFO, *LPTOOLINFO; 
uFlags标志可取下面值:

ValueMeaning
TTF_ABSOLUTE

Version 4.70 and later. Positions the tooltip window at the same coordinates provided byTTM_TRACKPOSITION. This flag must be used with the TTF_TRACK flag.

tooltip窗口的位置与TTM_TRACKPOSITION提供的坐标相同此标志必须TTF_TRACK标志使用

TTF_CENTERTIP

Centers the tooltip window below the tool specified by the uId member.

tooltip窗口在uId成员指定的工具的中心。

TTF_IDISHWND

Indicates that the uId member is the window handle to the tool. If this flag is not set,uId is the tool's identifier.

表示uId成员是工具的窗口句柄如果没有设置这个标志uid是该工具的标识符

TTF_PARSELINKS

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 XP or later. To use Comctl32.dll version 6, specify it in a manifest. For more information on manifests, seeEnabling Visual Styles.

表示解析tooltip文本链接

TTF_RTLREADING

Indicates that the tooltip text will be displayed in the opposite direction to the text in the parent window.

表示tooltip文本将在相反的方向显示在父窗口文本

TTF_SUBCLASS

Indicates that the tooltip control should subclass the tool's window to intercept messages, such asWM_MOUSEMOVE. If this flag is not set, you must use theTTM_RELAYEVENT message to forward messages to the tooltip control. For a list of messages that a tooltip control processes, see TTM_RELAYEVENT.

表示tooltip控件应该子类化工具的窗口进行拦截消息,WM_MOUSEMOVE如果没有设置这个标志,你必须使用TTM_RELAYEVENT的消息,将此消息发送到tooltip控件。让tooltip控件处理一个消息列表时,看到TTM_RELAYEVENT。

TTF_TRACK

Version 4.70 and later. Positions the tooltip window next to the tool to which it corresponds and moves the window according to coordinates supplied by theTTM_TRACKPOSITION messages. You must activate this type of tool using theTTM_TRACKACTIVATE message.

tooltip窗口旁边的工具,它根据的TTM_TRACKPOSITION消息提供的坐标来对应和移动窗口位置你必须使用TTM_TRACKACTIVATE消息激活此类型工具

TTF_TRANSPARENT

Version 4.70 and later. 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.

引起tooltip控件发送鼠标事件消息到父窗口这是有限的鼠标事件,此鼠标事件是发生在tooltip窗口范围

 TTGETTITLE Structure

typedef struct { 
  DWORD dwSize;        //指定结构的大小 
  UINT  uTitleBitmap;    //指定tooltip图标 
  UINT  cch;        //指定标题的字符数 
  WCHAR *pszTitle;    //指向包含标题的一个宽字符串的指针 
} TTGETTITLE, *PTTGETTITLE; 
TTHITTESTINFO Structure

typedef struct _TT_HITTESTINFO { 
  HWND     hwnd;    //工具或指定工具窗口的句柄 
  POINT    pt;        //测试的客户坐标点 
  TOOLINFO ti;        //如果pt点在hwnd所指定的工具上,获取工具信息 
} TTHITTESTINFO, *LPHITTESTINFO; 

参考资料:

http://msdn.microsoft.com/en-us/library/bb760246%28v=VS.85%29.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值