I would use checkboxes, then connect them to a function which updated a variable using the checkboxes state and bitshifting.
This is how you do it :
Create a few checkboxes - I will assume their names are IDC_MISREPORT_SHARE_1 to IDC_MISREPORT_SHARE_7.
In the message map of the pane, enter this :
Code: Select all
COMMAND_HANDLER(IDC_MISREPORT_SHARE_1, BN_CLICKED, onUpdateMisreportShare)
.
.
.
COMMAND_HANDLER(IDC_MISREPORT_SHARE_7, BN_CLICKED, onUpdateMisreportShare)
Then add the following to the public part of the class :
Code: Select all
LRESULT onUpdateMisreportShare(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
updateMisreportShare();
return 0;
}
Add the int variable mMisreportShare to the class (I'd recommend setting it to zero as well as
And add the following to the class (public or private does not matter - I would prefer private, though) :
Code: Select all
void updateMisreportShare() {
mMisreportShare = 0;
CButton btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_1);
if(btn.GetCheck())
mMisreportShare += 1;
btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_2);
if(btn.GetCheck())
mMisreportShare += 2;
btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_3);
if(btn.GetCheck())
mMisreportShare += 4;
btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_4);
if(btn.GetCheck())
mMisreportShare += 8;
btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_5);
if(btn.GetCheck())
mMisreportShare += 16;
btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_6);
if(btn.GetCheck())
mMisreportShare += 32;
btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_7);
if(btn.GetCheck())
mMisreportShare += 64;
}
void updateMisreportShareGUI() {
mMisreportShare = SETTING(MISREPORT_SHARE); // <-- should be an int setting
CButton btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_1);
btn.SetCheck((mMisreportShare & 1) > 0);
btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_2);
btn.SetCheck((mMisreportShare & 2) > 0);
btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_3);
btn.SetCheck((mMisreportShare & 4) > 0);
btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_4);
btn.SetCheck((mMisreportShare & 8) > 0);
btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_5);
btn.SetCheck((mMisreportShare & 16) > 0);
btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_6);
btn.SetCheck((mMisreportShare & 32) > 0);
btn = ::GetDlgItem(m_hWnd, IDC_MISREPORT_SHARE_7);
btn.SetCheck((mMisreportShare & 64) > 0);
}
Also, the following code must be added to the onInitDialog method :
The write() method should have this appended to it :
Code: Select all
SettingsManager::getInstance()->set(SettingsManager::MISREPORT_SHARE, mMisreportShare);
I assume that you have created a new IntSetting named MISREPORT_SHARE.
Good luck!
Sarf
---
If infinite rednecks fired infinite shotguns at an infinite number of road signs, they'd eventually create all the great literary works of the world in braille.