zoukankan      html  css  js  c++  java
  • CToolTipCtrl的使用实例MSDN

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

    创建并操纵一个CToolTipCtrl

    =======================

    1. 创建一个CToolTipCtrl的对象.

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

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

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

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

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

    7. 调用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);
    }
  • 相关阅读:
    根据自己的博客数据统计国内IT人群
    使用dropwizard(5)--加入swagger
    使用dropwizard(4)-加入测试-jacoco代码覆盖率
    使用dropwizard(3)-加入DI-dagger2
    收藏博客
    IntelliJ IDEA 下载安装(含注册码)
    fontawesome图标字体库组件在服务器上显示不出来图标的解决
    MySQL DBA工作角色和职责介绍
    MySQL主主复制(双主复制)配置过程介绍
    MySQL表与表之间的SQL Joins图介绍
  • 原文地址:https://www.cnblogs.com/awpatp/p/1597042.html
Copyright © 2011-2022 走看看