问题
I was originally thinking this would be extremely easy to do. Google searches returned results for everything but this.
I am trying to have a normal button that I can click, and it stays down, click again, and it rises back up.
I found one function that did what I wanted, but only worked if the button retained focus, click anywhere else and it rises again.
Button_SetState(GetDlgItem(hwnd, IDC_BTN_SLEEPCLICK), TRUE);
Is there any real way to do this? Or am I gonna need to do this kind of thing by hand?
Thanks.
回答1:
Create a check box, then set the "push like" property for that check box to true.
回答2:
You want a checkbox with BS_PUSHLIKE style. To toggle it programmatically, use Button_SetCheck
回答3:
The "staying down" and "rising back up" are a matter of how you draw the button.
You could create your own button class by using the Paint and Redraw methods.
来源:https://stackoverflow.com/questions/18369721/c-win32-how-to-create-a-toggle-pushbutton