我可以在MFC工具栏中制作一个无法单击的按钮/图标吗?

发布于 2024-10-08 17:17:43 字数 146 浏览 0 评论 0原文

我有一个 CMFCToolBar 的子类,其中包含一些按钮,一个用于切换设置,另一个用于显示当前状态(一次显示一个)。我需要其他按钮不可点击 - 如果用户点击它们,它们不应该被按下。有没有一种方法可以防止按下按钮而不将其禁用(因为这样它就会变灰)或将图标添加到没有交互的工具栏?

I have a subclass of CMFCToolBar that contains a few buttons, one for toggling a setting and the others for displaying the current state (shown one at a time). I need the other buttons to not be clickable- if the user clicks on them, they should not depress. Is there a way to prevent a button from depressing without making it disabled (because then it is grayed out) or to add an icon to a toolbar that has no interaction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟雨扶苏 2024-10-15 17:17:43

自从我完成 MFC 以来已经有一段时间了,所以我不太确定控件的名称,但我认为您可以在 CLabel (或者可能是 CLabelImage)中放置一个图标。您不想为此使用按钮,因为按钮应该被单击,即它看起来是可推动的。您想要类似仅显示状态的标签之类的东西,这就是标签的用途。

It's been a while since I've done MFC, so I'm not too sure of the name, of the control, but I think you can put an icon in a CLabel (or maybe CLabelImage). You don't want to use a button for this because a button is supposed to be clicked, i.e., it looks push-able. You want something like a label that just shows state, that's what labels are for.

满身野味 2024-10-15 17:17:43

仅处理按钮按下事件并重置按钮状态,然后什么也不做会更容易 - 并且可能更明智吗

Would it be easier - and potentially saner - to just handle the button press event and reset the button state, and then do nothing

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文