【问题标题】:How to add a tool tip to control in window application (win32 API) using Visual C++ 2008如何使用 Visual C++ 2008 在窗口应用程序(win32 API)中添加工具提示进行控制
【发布时间】:2009-12-02 10:54:50
【问题描述】:

我有一个 Visual C++ 中的窗口应用程序(win32 API),我必须在其中向控制按钮添加工具提示。任何人都可以帮助我完成上述任务吗?提前致谢。

【问题讨论】:

    标签: visual-c++


    【解决方案1】:

    如果您不使用 MFC 类,请参阅 About Tooltip Controls

    这是一个使用CToolTipCtrl类的例子,

    // Init a tooltip window    
    m_ToolTipCtrl = new CToolTipCtrl;
    m_ToolTipCtrl->Create( this ); // 'this', usually a CDialog window
    
    m_ToolTipCtrl->SetMaxTipWidth( 300 ); // if you need multiline messages
    m_ToolTipCtrl->SetTipBkColor( 0x000000 );
    m_ToolTipCtrl->SetTipTextColor( 0xe0e0d0 );
    
    // Attach a CListBox control (we can attach many controls)
    m_ToolTipCtrl->AddTool( plstBox, "Hey, i am a tooltip message!" );
    
    
    // ...
    // (*) We must use the following in order to use tooltips (MFC 4.0 and later versions)
    BOOL MyDialog::PreTranslateMessage(MSG* pMsg) 
    {
        if (NULL != m_ToolTipCtrl)
            m_ToolTipCtrl->RelayEvent(pMsg); // <- listen mouse messages!
    
    
        return CDialog::PreTranslateMessage(pMsg);
    }
    

    【讨论】:

    • 我没有使用 MFC,但是您的链接解决了我的问题,谢谢您的回复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    相关资源
    最近更新 更多