Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In my wim32 script have 2 radio buttons and want one press button IDC_BTN it read value of radio button that checked.
I tried this format:

C++
case IDC_BTN_BUYSTOP:

if ( SendMessage( GetDlgItem(hDlg1, IDC_RADIO1), BM_GETCHECK, 0,0 )== BST_CHECKED)
				nSel = 40; 
			
else if ( SendMessage( GetDlgItem(hDlg1, IDC_RADIO2), BM_GETCHECK, 0,0 )== BST_CHECKED)
				nSel = 50; 

			SetWindowLong(hDlg1, GWL_USERDATA, nSel);
                     
int res= GetWindowLong(hDlg1, GWL_USERDATA);

break;


return zero. tried this:
C++
case IDC_BTN_BUYSTOP:

if ( SendMessage( GetDlgItem(hDlg1, IDC_RADIO1), BM_GETCHECK, 0,0 ))
				nSel = 40; 
			
else if ( SendMessage( GetDlgItem(hDlg1, IDC_RADIO2), BM_GETCHECK, 0,0 ))
				nSel = 50; 

			SetWindowLong(hDlg1, GWL_USERDATA, nSel);
                     
int res= GetWindowLong(hDlg1, GWL_USERDATA);

break;


return zero. and another
C++
case IDC_BTN_BUYSTOP:

if ( ::SendMessage( GetDlgItem(hDlg1, IDC_RADIO1), BM_GETCHECK, 0,0 ))
				nSel = 40; 
			
else if ( ::SendMessage( GetDlgItem(hDlg1, IDC_RADIO2), BM_GETCHECK, 0,0 ))
				nSel = 50; 

			SetWindowLong(hDlg1, GWL_USERDATA, nSel);
                     
int res= GetWindowLong(hDlg1, GWL_USERDATA);

break;


return zero again.
What is correct format?
Regards,
Posted
Comments
Richard MacCutchan 3-Oct-13 8:49am    
I just tried this and it works fine; where are you getting zero returned?
AlwaysLearningNewStuff 6-Oct-13 11:03am    
You should add {} to your case statement, since you define integer variable res.

Regards.
The_Inventor 6-Oct-13 22:51pm    
I didn't see any code that returned anything. Where is your 'return res;'?
Albert Holguin 15-Oct-13 14:37pm    
The SendMessage() calls return a value...
Albert Holguin 15-Oct-13 14:40pm    
There is more than one format that is correct... but your problem statement doesn't specify what you're doing and when you encounter the problem. Do you even know that you're getting to the SendMessage() calls?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900