Radio button selection change in MFC -
using mfc have created dialog, having 5 radio buttons. want notification when other radio-button gets selected.
for notification whenever of radio button clicked. need gets these notification when there change in radio button.
on_bn_clicked(idc_radio1, &cmydlg::onradiobuttonclicked) on_bn_clicked(idc_radio1, &cmydlg::onradiobuttonclicked) on_bn_clicked(idc_radio1, &cmydlg::onradiobuttonclicked) on_bn_clicked(idc_radio1, &cmydlg::onradiobuttonclicked) on_bn_clicked(idc_radio1, &cmydlg::onradiobuttonclicked) thanks
if understand question correctly, want know when checked state of 1 particular radio button (idc_radio1) changes.
then store state member variable in dialog class. int m_radio1checked; initialise in constructor 0 or 1 want, , use setcheckradiobutton() appropriately in oninitdialog().
then handle clicking of each radio button in message map:
on_bn_clicked(idc_radio1, &cmydlg::onradiobuttonclicked) on_bn_clicked(idc_radio2, &cmydlg::onradiobuttonclicked) on_bn_clicked(idc_radio3, &cmydlg::onradiobuttonclicked) on_bn_clicked(idc_radio4, &cmydlg::onradiobuttonclicked) on_bn_clicked(idc_radio5, &cmydlg::onradiobuttonclicked) and in handler check change.
void cmydlg::onradiobuttonclicked() { int oldstate = m_radio1checked; int newstate = getdlgitem(idc_radio1)->getchecked(); m_radio1checked = newstate; if (oldstate != newstate) // ... }
Comments
Post a Comment