How to tell when an autocheckbox has been checked?

hello I was wondering how to tell when a user checks a autocheckbox(BS_AUTOCHECKBOX)
I have tried a couple things with no luck If there is a button message or something let me know which message to check for...

for example I want to set a couple variables once a check box has been checked..
I was thinking it might be BM_GETCHECK or something along those lines but im not sure and MSDN wasn't very helpful from what I could find.

Thanks in advanced.
Last edited on
Handle the WM_COMMAND then call IsDlgButtonChecked
http://msdn.microsoft.com/en-us/library/bb761879(v=vs.85).aspx

Good luck!!
ok so this is what I did and I have 3 buttons but the second button will uncheck no matter what buton I press... even its self

1
2
3
4
5
6
7
case WM_COMMAND :
            if (wParam==IsDlgButtonChecked(checkBoxButton[0],BST_CHECKED))
            {
                SendMessage(checkBoxButton[1],BM_SETCHECK,BST_UNCHECKED,0);
            }

            break;
Last edited on
Assuming checkBoxButton is an Array of HWND. Try this

1
2
3
4
5
6
7
8
9
10
11
case WM_COMMAND :
    switch(LOWORD(wParam))
    {
        case CHECKBOX0: //this depends on how you created the checkbox
            if (IsDlgButtonChecked(hWnd, LOWORD(wParam))==BST_CHECKED)
            {
                SendMessage(checkBoxButton[1], BM_SETCHECK, BST_UNCHECKED, 0);
            }
            break;
    }
    break;


or this

1
2
3
4
5
6
case WM_COMMAND :
    if (lParam==checkBoxButton[0])
    {
        if (Button_GetState(checkBoxButton[0])==BST_CHECKED)
            Button_SetCheck(checkBoxButton[1], BST_UNCHECKED);
    }


http://msdn.microsoft.com/en-us/library/bb849164(v=VS.85).aspx
http://msdn.microsoft.com/en-us/library/bb849167(v=VS.85).aspx
ok for the second one i get these errors
1
2
3
4
5
C:\Projects\EEbot_v2\main.cpp||In function 'LRESULT WindowProcedure(HWND__*, UINT, WPARAM, LPARAM)':|
C:\Projects\EEbot_v2\main.cpp|80|error: ISO C++ forbids comparison between pointer and integer|
C:\Projects\EEbot_v2\main.cpp|82|error: 'Button_GetState' was not declared in this scope|
C:\Projects\EEbot_v2\main.cpp|83|error: 'Button_SetCheck' was not declared in this scope|
||=== Build finished: 3 errors, 0 warnings ===|


and for the first one I get these errors

1
2
3
4
C:\Projects\EEbot_v2\main.cpp||In function 'LRESULT WindowProcedure(HWND__*, UINT, WPARAM, LPARAM)':|
C:\Projects\EEbot_v2\main.cpp|82|error: 'CHECKBOX0' was not declared in this scope|
C:\Projects\EEbot_v2\main.cpp|83|error: 'hWnd' was not declared in this scope|
||=== Build finished: 2 errors, 0 warnings ===|
Getting the checked state of a radio button or check box is about as simple as it gets --

if(SendDlgItemMessage(hwnd, ID_BOX, BM_GETCHECK,TRUE,0)==BST_CHECKED)...
Last edited on
Incidentally, if you want to trap for each time the button is checked/unchecked automatically, then set this in your WM_COMMAND statement, like so...

1
2
3
4
5
6
7
8
9
10
11
12
case WM_COMMAND:
switch(LOWORD(wParam))
{
     case ID_BOX:
          if(SendDlgItemMessage(hwnd,ID_BOX,BM_GETCHECK,TRUE,0)==BST_CHECKED)
          {
                ...then do whatever you want
          }
          else
          {
               ...then do something else
           }

How do you find the ID of the box? or do I just have to declare ID_BOX... cause its saying ID_BOX not declared in this spectrum.
The ID is the value you pass to CreateWindow or CreateWindowEx's HMENU paramenter.

http://msdn.microsoft.com/en-us/library/ms632679(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms632680(v=vs.85).aspx
Topic archived. No new replies allowed.