我可以在MFC工具栏中制作一个无法单击的按钮/图标吗?
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
自从我完成 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.
仅处理按钮按下事件并重置按钮状态,然后什么也不做会更容易 - 并且可能更明智吗
Would it be easier - and potentially saner - to just handle the button press event and reset the button state, and then do nothing