-
Checkboxes
I was able to find out how to create a checkbox through a resource with a simple google search, but I can't for the life of me find anything about using one. A little clever MessageBox-ing told me that when I click the box, even though nothing seems to happen, the message is being sent to my dialog. However, I don't know what to do next. Any advice or sample code?
-
Add the message handler to the message map.
ON_BN_CLICKED(checkboxID, CallbackFunction)
Kuphryn
-
Add that piece of code under the case for the button's Message? Sweet. Thanks. That's all I needed.
-
Okay, maybe that wasn't all. I'm getting an undefined reference error for ON_BN_CLICKED. I ran a search, and it doesn't exist in any of my header files. Did you not mean that literally like you didn't mean checkboxID literally?
-
Are you using MFC or the API directly?? The answer to the question will vary depending on what you're using.
Cheers.
-
-
-
The BN_CLICKED notification that Knutso has kindly provided a link to will tell you when your checkbox has been clicked (search this board as there are plenty of examples of its use). In order to find out whether the checkbox is checked or not, you'll need to send the checkbox a BM_GETCHECK message with SendMessage; the return value will give you the check state. The IsDlgButtonChecked function accomplishes the same thing.
-
So, basically, sending that when the box is clicked switches its state?
-
No, that tells you its current state. The action of clicking will change its state, of course, but if you want to manually change it then send the control a BM_SETCHECK message.
-
Yeah. I only recently discovered the wonders of MSDN, so I was able to figure that out myself. Sorry to have bothered you guys, and thanks for helping anyway.