简体   繁体   English

C ++ WinAPI-如何使按钮显示为按下状态?

[英]C++ WinAPI - How to make button appear pressed?

I have in my editor few editing modes. 我的编辑器中有几种编辑模式。 I can choose specific mode using buttons that are placed on a toolbar. 我可以使用工具栏上的按钮选择特定模式。 I want to indicate which mode is currently on. 我想指出当前处于哪种模式。 When I press appropriate button - I want to make the clicked button remain pushed. 当我按下适当的按钮时-我想使单击的按钮保持按下状态。 How do I do that in WinAPI? 如何在WinAPI中做到这一点? My toolbar uses bitmaps for icons if that's relevant. 如果相关,我的工具栏将位图用于图标。

There used to be a way to get something like the look and feel of a toolbar by using a normal check box with the BS_PUSHLIKE style set. 过去有一种方法可以通过使用设置了BS_PUSHLIKE样式的普通复选框来获得类似工具栏外观的效果。 But that got broken a bit with Windows XP because of mouse hover effects, so it's not widely used any more. 但这由于鼠标悬停效果而在Windows XP中被破坏了一点,因此它不再被广泛使用。

If you want to create your own toolbar, without the help of MFC, there is an MSDN article that covers the creation and management of a toolbar window (actually a dedicated window class as part of the Common Controls Library). 如果要创建自己的工具栏,而无需MFC的帮助,则有MSDN文章介绍工具栏窗口的创建和管理(实际上是专用窗口类,它是Common Controls库的一部分)。

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

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