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.
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;
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);
}
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 ===|
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
}