Archive: Changing checkbox state using SendMessage - WM_???


Changing checkbox state using SendMessage - WM_???
Is it possible to change the state of a checkbox using SendMessage? I need to load a set of checkbox states based on user input on a custom page and I'm stuck with a typical InstallOptions limitation - once the page is shown, changes in the .ini are not reflected on the page. I usually deal with this by updating controls using either EnableWindow or SendMessage but I don't know which message (if any) can be used to change a checkbox state. Can anybody help (without advising me to use nsDialogs)?


Well, I'm going to advise you to take a look at nsDialogs. Not saying you need to switch, but look at its include file, it will tell you the win32 message to use. A checkbox is really a button in win32 so its messages start with BM_*


BM_SETCHECK (0x00f1)
SendMessage hwnd_checkbox BM_SETCHECK state 0
where 'state' is one of:
0: unchecked
1: checked
2: indeterminate (must be supported by the styles on the checkbox)

Depending on whether or not that checkbox performs any actions when toggled, you may also wish to send a BN_CLICKED notification.


Yep, problem solved. Thanks, both of you!