简体   繁体   中英

How can I “unclick” a button in C++ Builder 6

I have a button in C++ Builder 6 that I need to activate (and stay activated). But when I don't need it anymore, I want to click again on that button, and it goes back to the UP state.

Thank you for your help.

if you're working with VCL controls I think you can use a TSpeedButton and implement the toggle logic with its TSpeedButton.Down property. It stays pressed while Down is true and unpressed when Down is false. Check this

there are these properties for this:

  • TSpeedButton::Down indicates clicked button (you can also programaticaly set it to true/false on runtime)
  • TSpeedButton::AllowUp enable unclicking on second click
  • TSpeedButton::GroupIndex if non zero all buttons with the same index are goruped together and only one can be down at time so when you click on one all others are unclicked.

So for single button set AllowUp=true And GroupIndex to unique non zero number and for multiple buttons just set GroupIndex to the same unique non zero number for all buttons.

Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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