-
ShowWindow Problem
I'm trying to enable or disable some controls on my window depending on a Combo Box list selection.....
I've used this before with a Check Box selection and it worked OK, nevertheless it only gives me two diferent options (ON or OFF) and I would like to have more options....
Below the code I've used with success on a Check Box selection, Can anyone give an Idea on how to accomplish this in a ComboBox....
==============================================
void Dialog::OnCheck1()
{
UpdateData(TRUE);
if (m_Selection == TRUE)
{
GetDlgItem(IDC_HSN) ->ShowWindow(TRUE);
}
else
{
GetDlgItem(IDC_HSN) ->ShowWindow(FALSE);
}
}
==============================================
-
First of all, in that OnCheck1() function a much simpler way to do that is this one-liner:
Code:
GetDlgItem(IDC_HSN)->ShowWindow(((CButton*)GetDlgItem(IDC_CHECKBTN))->GetCheck() == 1);
For a combo box:
Code:
GetDlgItem(IDC_WHATEVER)->ShowWindow(m_ComboBox.GetCurSel() == YOUR_INDEX);
-
Hummm.... that's interesting.... nevertheless I'm still having problems.. I want to show some Static Text and hide another Static Text depending on the Selection... but somehow is not working.... could someone help me please... My idea is to enable the Static Text "2308" and disable Static Text "2106" when this option is selected in the combo Box ...
Below the code i'm using:
==============================================
void CComboBoxDlg::OnEditchangeRbs()
{
UpdateData(TRUE);
GetDlgItem(IDC_2308)->ShowWindow(m_RBS.GetCurSel() == 2308);
GetDlgItem(IDC_2106)->ShowWindow(m_RBS.GetCurSel() == 2106);
UpdateData(FALSE);
}
-
Nevermind guys... I've found my mistake.... I selected OnEditChange() insted of selecting OnSelChange()...
I just had to change that and do some minor adjustments to have everything like I wanted..... dumb a___ it was just in front of me and I didn't see it... thanks for the help anyway luckY ... :p
-
Let me get this straight. If the current selection is index 2308 or 2106 you want to do the showing/unshowing stuff. Is that right? (You have over 2300 items in your list?) If that is right, it should work. However, I'm guessing that isn't correct. The GetCurSel() function returns the zero-based index of the currently selected item in the combo box, so you should be checking it's equality with 0 if it's the first item in the list, 1 if the second, etc. Does that help?
[edit]
No problem, amigo.
[/edit]