CToolTipCtrl

MSDN CToolTioCtrl类介绍

Visual Studio 6.0

CToolTipCtrl Class Members

Construction

CToolTipCtrl Constructs aCToolTipCtrlobject.
Create Creates a tool tip control and attaches it to aCToolTipCtrlobject.

Attributes

GetText Retrieves the text that a tool tip control maintains for a tool.
GetToolInfo Retrieves the information that a tool tip control maintains about a tool.
SetToolInfo Sets the information that a tool tip maintains for a tool.
GetToolCount Retrieves a count of the tools maintained by a tool tip control.
GetDelayTime Retrieves the initial, pop-up, and reshow durations currently set for a tool tip control.
SetDelayTime Sets the initial, pop-up, and reshow durations for a tool tip control.
GetMargin Retrieves the top, left, bottom, and right margins set for a tool tip window.
SetMargin Sets the top, left, bottom, and right margins for a tool tip window.
GetMaxTipWidth Retrieves the maximum width for a tool tip window.
SetMaxTipWidth Sets the maximum width for a tool tip window.
GetTipBkColor Retrieves the background color in a tool tip window.
SetTipBkColor Sets the background color in a tool tip window.
GetTipTextColor Retrieves the text color in a tool tip window.
SetTipTextColor Sets the text color in a tool tip window.

Operations

Activate Activates and deactivates the tool tip control.
AddTool Registers a tool with the tool tip control.
DelTool Removes a tool from the tool tip control.
HitTest Tests a point to determine whether it is within the bounding rectangle of the given tool and, if so, retrieves information about the tool.
RelayEvent Passes a mouse message to a tool tip control for processing.
SetToolRect Sets a new bounding rectangle for a tool.
UpdateTipText Sets the tool tip text for a tool.
Update Forces the current tool to be redrawn.
Pop Removes a displayed tool tip window from view.

如何操纵CToolTipCtrl来给自己的控件添加tool tip呢?MSDN给出了答案。

创建并操纵一个CToolTipCtrl
创建一个CToolTipCtrl的对象.

调用Create函数来创建windows通用提示控件并使之与CToolTipCtrl对象产生关联。

调用AddTool函数来把tool tip control注册到一个tool上,这样存储在tool tip中的信息就能在光标悬浮在这个tool上的时候显示出来。

调用SetToolInfo来设置tool tip为这个tool所保留的信息。

调用SetToolRect来设置该tol的一个新的范围矩形。

调用HitTest函数来判断一个点是否在某个给定tool的范围矩形之内,如果是的话,就返回这个tool的信息。

调用GetToolCount来得到一个tool tip所关联到的tool的个数。

// Create and associate a tooltip control to the tab control of
// CMyPropertySheet. CMyPropertySheet is a CPropertySheet-derived
// class.
BOOL CMyPropertySheet::OnInitDialog()
...{
BOOL bResult = CPropertySheet::OnInitDialog();

// Create a tooltip control. m_ToolTipCtrl is a member variable
// of type CToolTipCtrl* in CMyPropertySheet class. It is
// initialized to NULL in the constructor, and destroyed in the
// destructor of CMyPropertySheet class.
m_ToolTipCtrl = new CToolTipCtrl;// 第一步,创建对象
if (!m_ToolTipCtrl->Create(this)) //第二步,调用Create函数
...{
TRACE("Unable To create ToolTip ");
return bResult;
}

// Associate the tooltip control to the tab control
// of CMyPropertySheet.
CTabCtrl* tab = GetTabControl();
tab->SetToolTips(m_ToolTipCtrl);
// Get the bounding rectangle of each tab in the tab control of the
// property sheet. Use this rectangle when registering a tool with
// the tool tip control. IDS_FIRST_TOOLTIP is the first ID string
// resource that contains the text for the tool.
int count = tab->GetItemCount();
int id = IDS_FIRST_TOOLTIP;
for (int i = 0; i < count; i++)
...{
id += i;
CRect r;
tab->GetItemRect(i, &r);
VERIFY(m_ToolTipCtrl->AddTool(tab, id, &r, id));
}

// Activate the tooltip control.
m_ToolTipCtrl->Activate(TRUE);

return bResult;
}

// Override PreTranslateMessage() so RelayEvent() can be
// called to pass a mouse message to CMyPropertySheet's
// tooltip control for processing.
BOOL CMyPropertySheet::PreTranslateMessage(MSG* pMsg)
...{
if (NULL != m_ToolTipCtrl)
m_ToolTipCtrl->RelayEvent(pMsg);

return CPropertySheet::PreTranslateMessage(pMsg);
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值