c++ win32 创建纯文本按钮
我想向我的 c++ win32 应用程序添加一个简单的文本按钮。我正在使用 CreateWindowEx 函数创建按钮,但无法找出正确的样式。我想显示一个纯文本按钮,并能够在用户单击它时接收消息。我想要的样式与 Windows 7 系统音量控制中的文本按钮(其中写着“混音器”)相同。如果可能的话我也想显示一个工具提示。
I would like to add a simple text button to my c++ win32 application. I'm creating the button using CreateWindowEx function, but can't figure out the correct style to do so. 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"). If possible i would like to display a tooltip also.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该混音器控件看起来更像是超链接控件而不是按钮。我会选择
SysLink
控制是否是您所需要的。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.您可以创建一个具有 BS_OWNERDRAW 样式的“Button”类窗口并处理 WM_DRAWITEM 消息。在 WM_DRAWITEM 消息处理程序中,您可以简单地显示文本。
You could create a "Button" class window with the BS_OWNERDRAW style and handle the WM_DRAWITEM messages. In your WM_DRAWITEM message handler you can simply display the text.
实际上,该按钮是一个所有者绘制按钮 - 它监听鼠标移动消息,当您将鼠标悬停在其上时,它会在文本下划线(syslink 控件没有此行为)。否则它就是一个股票按钮。
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). Otherwise it's a stock button.