zoukankan      html  css  js  c++  java
  • MFC控件(15):Tooltip

    在各种软件产品中我们经常碰到把鼠标放到一个控件上时会弹出关于该控件的一些提示信息.这就是tooltip.

    在MFC中使用该功能可以使用类CToolTipCtrl.假如要让鼠标放到按钮IDC_BTN上时弹出提示信息.用法如下

    1.定义变量

    CToolTipCtrol m_tooltip;

    2.初始化,一般放到OnInitDialog()中

    m_tooltip.Create(this);

    CString strInfo = _T("Get more detailed info");

    m_tooltip.AddTool(  GetDlgItem(IDC_BTN)  ,strInfo);

    m_toolTip.Activate(TRUE);

    // m_tooltip.SetDelayTime(150); //设置弹出提示信息过多久就消失

    m_tooltip.SetTipTextColor(RGB(255, 0, 0)); //设置显示的字的颜色,不过试了下貌似显示不出来颜色.不知道是啥原因.

    //有人说m_tooltip.SetWindowTheme(_T(""));这样试下可以.但我试了反正是不行.

    3.消息处理

    virtual BOOL PreTranslateMessage(MSG* pMsg);

    BOOL CMFCDlg::PreTranslateMessage(MSG* pMsg)

    {

      if (pMsg->message == WM_MOUSEMOVE )

          m_tooltip.RelayEvent(pMsg);

    return CDialog::PreTranslateMessage(pMsg);

    }

  • 相关阅读:
    117. Populating Next Right Pointers in Each Node II
    116. Populating Next Right Pointers in Each Node
    DFS & BFS
    Binary Search
    博客保存
    python强大的正则表达式
    游戏注意的地方
    vim使用
    下一步的
    lua的动态特性
  • 原文地址:https://www.cnblogs.com/riskyer/p/3290142.html
Copyright © 2011-2022 走看看