visual-c++ - 如何使用 Visual C++ 2008 添加工具提示来控制窗口应用程序 (win32 API)

标签 visual-c++

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

最佳答案

如果您不使用 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);
}

关于visual-c++ - 如何使用 Visual C++ 2008 添加工具提示来控制窗口应用程序 (win32 API),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1832165/

相关文章:

c++ - C++ 代码从 Linux 到 Windows 的转换

c++ - 显示最初隐藏的无模型对话框

c++ - 与 MingW 相比,Visual C++ 中的不同行为

visual-c++ - 如何为 64 位 Windows 编译 omniORB?

c# - VC++ 中 "object of C# "的等价物是什么?

visual-c++ - Media Foundation EVR 无视频显示

C++ 无法填充 C 数组的映射

c++ - 在最佳时间从 _variant_t 获取 char*

visual-c++ - 使用make_pair时在Visual Studio 2012中使用c2664

c++ - 为什么我的 Winsock 应用程序有时在 listen() 等待,有时在 accept() 等待?