Thread: ShowWindow Problem

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    47

    Question 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);
    }
    }
    ==============================================
    I'm a person with a simple taste...
    I only like the best.

  2. #2
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    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);

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    47
    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);
    }
    I'm a person with a simple taste...
    I only like the best.

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    47
    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 ...
    I'm a person with a simple taste...
    I only like the best.

  5. #5
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    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]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM