Tuesday, May 11, 2004

VC++ radio button

The first button's "group" is checked and all the other buttons are unchecked. The examples can be found here.
The "Run" button drives the "OnTimer()" running and the initialization function and UpdateData(FALSE) will run in a loop, so the radio button will keep the initial status (first button is checked). We need to transfer the value to the radio button with UpdateData(TRUE):

void CDlgOglDlg::OnBnClickedRadio1()
{m_pclGlView->NEAREST = 0.04;

The UpdateData function is the key to working with control variables in Visual C++. If the augument is FALSE, the values in the variables are passed to the controls on the window. If the augument is TRUE, the variables are updated with whatever appears in the controls on the window.

BOOL UpdateData(Flag);
Flag that indicates whether dialog box is being initialized (FALSE, value to control) or data is being retrieved (TRUE, control to value).

several other function to get and set radio button status:
CButton *Radio1_check, *Radio2_check;
Radio1_check=(CButton *)GetDlgItem(IDC_RADIO1);
Radio2_check=(CButton *)GetDlgItem(IDC_RADIO2);
int a = Radio1_check->GetCheck();
int b = Radio2_check->GetCheck();

No comments:

Post a Comment