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 clickTSpeedButton::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!