I finally figured out how to set a radio button in my dialog to my 'default' state that I want.
Now, I want to check to see if the user selects my other radio button and when he or she does to change the value of a variable to a negative number. When I tried using BM_GETCHECKED my compiler chokes and says it is an undeclared identifier.
What is the correct way to implement this?
I've rem'd out the various things that I have tried below.
Here is the code I tried...
Code:
BOOL CALLBACK CircleProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
int nLen = 0;
LPTSTR pbuffer = NULL;
switch(Message)
{
case WM_INITDIALOG:
// Default radio button.
hdlg = GetDlgItem(hwnd,IDC_RADIO_ADD );
SendMessage(hdlg, BM_SETCHECK, 1,0);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
{
hdlg = GetDlgItem(hwnd, IDC_EDIT_DIAMETER); //(hOwner, hDialogEditField)
nLen = GetWindowTextLength(hdlg);
pbuffer = (LPTSTR)malloc(nLen + 1);
GetDlgItemText(hwnd, //(hOwner, hDialogEditField)
IDC_EDIT_DIAMETER, // control identifier
pbuffer, // pointer to buffer for text
nLen+1 // maximum size of string + NULL
);
// pbuffer is valid so do calculations.
diameter = strtod(pbuffer, NULL);
free(pbuffer);
Ixc = (PI/64)*(pow(diameter, 4.0));
area = PI * pow(diameter/2, 2);
// Here are the varoius things that I have tried.
// int iCheck;
// iCheck = SendMessage (IDC_RADIO_SUBTRACT, BM_GETCHECKED, 0, 0);
//if(Button_GetCheck(hwnd,IDC_RADIO_ADD ))
// if (iCheck != 0)
// area = -1*area;
}
// Since OK call center coord. dialog.
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(ID_CENTER_COORDINATES),
hwnd, CenterCoordinates);
EndDialog(hwnd, IDOK);
break;
case IDCANCEL:
MessageBeep (0) ;
EndDialog(hwnd, IDCANCEL);
break;
}
break;
default:
return FALSE;
}
return TRUE;
}