此方法适用于MFC派生类,在基于对话框的类中测试通过。具体步骤如下:

 

1、选择“Project”菜单,然后“Set Active Project

2、选择“Project”菜单 -->Add to Project -->Components and Controls -->VC++ Components --> ToolTip Support

3、选择“Insert

4、在对话框资源中加入一个按钮,IDIDC_ToolTip

5、在 CDialog::OnInitDialog() 中找到下面的注释行:

 

   // TODO: Use one of the following forms to add controls:

   // m_tooltip.AddTool(GetDlgItem(IDC_), );

   // m_tooltip.AddTool(GetDlgItem(IDC_), "");

然后在注释行后加入一行代码:

   m_tooltip.AddTool(GetDlgItem(IDC_ToolTip), "显示 ToolTip");

 

 

经过上面的步骤之后:

 

头文件(*.h)中会自动加入下面的代码:

   public:

      virtual BOOL PreTranslateMessage(MSG* pMsg);

 

实现文件(*.cpp)会加入方法实现:

      PreTranslateMessage(MSG* pMsg);

 

编译程序执行吧,将鼠标指针移到ToolTip按钮上就会显示出一个ToolTip信息。

相关文章:

猜你喜欢
相关资源
相似解决方案