简体   繁体   English

c ++ win32创建一个纯文本按钮

[英]c++ win32 create a text only button

I would like to add a simple text button to my c++ win32 application. 我想在我的c ++ win32应用程序中添加一个简单的文本按钮。 I'm creating the button using CreateWindowEx function, but can't figure out the correct style to do so. 我正在使用CreateWindowEx函数创建按钮,但无法找出正确的样式。 I would like to display a text only button and be able to recive messages when the user clicks on it. 我想显示一个纯文本按钮,并能够在用户点击它时收到消息。 The style i would like to get is identical to the text button in windows 7 system volume control (where it says "Mixer"). 我想要的样式与Windows 7系统音量控制中的文本按钮相同(其中它表示“混音器”)。 If possible i would like to display a tooltip also. 如果可能的话,我也想显示一个工具提示。

在此输入图像描述

That mixer control looks more like a hyperlink control than a button. 混音器控件看起来更像是超链接控件而不是按钮。 I'd go for the SysLink control if that's what you need. 如果那就是你需要的,我会选择SysLink控件。

You could create a "Button" class window with the BS_OWNERDRAW style and handle the WM_DRAWITEM messages. 您可以使用BS_OWNERDRAW样式创建“Button”类窗口并处理WM_DRAWITEM消息。 In your WM_DRAWITEM message handler you can simply display the text. 在WM_DRAWITEM消息处理程序中,您只需显示文本即可。

Actually that button is an owner draw button - it listens to mouse move messages and when you hover over it, it underlines the text (the syslink control doesn't have this behavior). 实际上,该按钮是一个所有者绘制按钮 - 它侦听鼠标移动消息,当您将鼠标悬停在它上面时,它会强调文本(syslink控件没有此行为)。 Otherwise it's a stock button. 否则它是一个股票按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM