Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. EnableWindow Help

EnableWindow Help

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++tutorialquestion
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    celllllllll
    wrote on last edited by
    #1

    Hi All, I posted my question earlier also but wasn't really satisfied. So, asking it again. I have two comboboxes and if I select first item from first combobox then the second combobox should be disabled. And if I select any other items expect the first item from the first combobox, then the second combo box should be enabled. I know how to disble and enable a window(using EnableWindow) but the problem I have is that I am not able to select that first item in the first combobox selecting which I disable my second combobox. In the following code, I was trying it using GetCurSel and SetCurSel but it doesn't work. In the code, m_Au is the member of first combobox. V is the first item in the first combobox of #define type. m_C is the member of Second Combobox. int nToken = m_Au.GetCurSel(); m_Au.SetCurSel(0); if (nToken == V) { m_C.EnableWindow(FALSE); } else { m_C.EnableWindow(TRUE); } I populated my second combobox dynamically based on the first combobox. So, I mean to say that they are related to each other. I will really appreciate the help.

    C++Prog

    M E H 4 Replies Last reply
    0
    • C celllllllll

      Hi All, I posted my question earlier also but wasn't really satisfied. So, asking it again. I have two comboboxes and if I select first item from first combobox then the second combobox should be disabled. And if I select any other items expect the first item from the first combobox, then the second combo box should be enabled. I know how to disble and enable a window(using EnableWindow) but the problem I have is that I am not able to select that first item in the first combobox selecting which I disable my second combobox. In the following code, I was trying it using GetCurSel and SetCurSel but it doesn't work. In the code, m_Au is the member of first combobox. V is the first item in the first combobox of #define type. m_C is the member of Second Combobox. int nToken = m_Au.GetCurSel(); m_Au.SetCurSel(0); if (nToken == V) { m_C.EnableWindow(FALSE); } else { m_C.EnableWindow(TRUE); } I populated my second combobox dynamically based on the first combobox. So, I mean to say that they are related to each other. I will really appreciate the help.

      C++Prog

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      celllllllll wrote:

      I have two comboboxes and if I select first item from first combobox then the second combobox should be disabled. And if I select any other items expect the first item from the first combobox, then the second combo box should be enabled.

      if (0 == m_Au.GetCurSel())
      {
      m_C.EnableWindow(FALSE);
      }
      else
      {
      m_C.EnableWindow(TRUE);
      }

      C 1 Reply Last reply
      0
      • M Mark Salsbery

        celllllllll wrote:

        I have two comboboxes and if I select first item from first combobox then the second combobox should be disabled. And if I select any other items expect the first item from the first combobox, then the second combo box should be enabled.

        if (0 == m_Au.GetCurSel())
        {
        m_C.EnableWindow(FALSE);
        }
        else
        {
        m_C.EnableWindow(TRUE);
        }

        C Offline
        C Offline
        celllllllll
        wrote on last edited by
        #3

        I really appreciate the answer but it doesn't work. It is disabling the second combobox for every selection in first combobox. So, basically we can say the "if" statement isn't working. Thanks for the help and reading the whole problem. Thank You

        C++Prog

        M 1 Reply Last reply
        0
        • C celllllllll

          I really appreciate the answer but it doesn't work. It is disabling the second combobox for every selection in first combobox. So, basically we can say the "if" statement isn't working. Thanks for the help and reading the whole problem. Thank You

          C++Prog

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Where are you calling this code - in response to a CBN_SELCHANGE message? Are you still doing that m_Au.SetCurSel(0) ?? How about breaking it down...If you change the code as follows and put a breakpoint on the "if" line....what is the value of CurSel when you select say, the second item in the list?

          int CurSel = m_Au.GetCurSel();
          if (0 == CurSel)
          {
          m_C.EnableWindow(FALSE);
          }
          else
          {
          m_C.EnableWindow(TRUE);
          }

          1 Reply Last reply
          0
          • C celllllllll

            Hi All, I posted my question earlier also but wasn't really satisfied. So, asking it again. I have two comboboxes and if I select first item from first combobox then the second combobox should be disabled. And if I select any other items expect the first item from the first combobox, then the second combo box should be enabled. I know how to disble and enable a window(using EnableWindow) but the problem I have is that I am not able to select that first item in the first combobox selecting which I disable my second combobox. In the following code, I was trying it using GetCurSel and SetCurSel but it doesn't work. In the code, m_Au is the member of first combobox. V is the first item in the first combobox of #define type. m_C is the member of Second Combobox. int nToken = m_Au.GetCurSel(); m_Au.SetCurSel(0); if (nToken == V) { m_C.EnableWindow(FALSE); } else { m_C.EnableWindow(TRUE); } I populated my second combobox dynamically based on the first combobox. So, I mean to say that they are related to each other. I will really appreciate the help.

            C++Prog

            E Offline
            E Offline
            Eytukan
            wrote on last edited by
            #5

            celllllllll wrote:

            m_Au.SetCurSel(0);

            Why are you still doing it :doh:?


            :Gong: 歡迎光臨 吐 西批 :Gong:

            1 Reply Last reply
            0
            • C celllllllll

              Hi All, I posted my question earlier also but wasn't really satisfied. So, asking it again. I have two comboboxes and if I select first item from first combobox then the second combobox should be disabled. And if I select any other items expect the first item from the first combobox, then the second combo box should be enabled. I know how to disble and enable a window(using EnableWindow) but the problem I have is that I am not able to select that first item in the first combobox selecting which I disable my second combobox. In the following code, I was trying it using GetCurSel and SetCurSel but it doesn't work. In the code, m_Au is the member of first combobox. V is the first item in the first combobox of #define type. m_C is the member of Second Combobox. int nToken = m_Au.GetCurSel(); m_Au.SetCurSel(0); if (nToken == V) { m_C.EnableWindow(FALSE); } else { m_C.EnableWindow(TRUE); } I populated my second combobox dynamically based on the first combobox. So, I mean to say that they are related to each other. I will really appreciate the help.

              C++Prog

              E Offline
              E Offline
              Eytukan
              wrote on last edited by
              #6

              May be you'd want to keep the selection back to the first item after a selection has been made, so you should put it in the bottom. eg :int nToken = m_Au.GetCurSel(); **m_Au.SetCurSel(0);** if (nToken == V) { m_C.EnableWindow(FALSE); } else { m_C.EnableWindow(TRUE); } **m_Au.SetCurSel(0);** //<------- Here


              :Gong: 歡迎光臨 吐 西批 :Gong:

              1 Reply Last reply
              0
              • C celllllllll

                Hi All, I posted my question earlier also but wasn't really satisfied. So, asking it again. I have two comboboxes and if I select first item from first combobox then the second combobox should be disabled. And if I select any other items expect the first item from the first combobox, then the second combo box should be enabled. I know how to disble and enable a window(using EnableWindow) but the problem I have is that I am not able to select that first item in the first combobox selecting which I disable my second combobox. In the following code, I was trying it using GetCurSel and SetCurSel but it doesn't work. In the code, m_Au is the member of first combobox. V is the first item in the first combobox of #define type. m_C is the member of Second Combobox. int nToken = m_Au.GetCurSel(); m_Au.SetCurSel(0); if (nToken == V) { m_C.EnableWindow(FALSE); } else { m_C.EnableWindow(TRUE); } I populated my second combobox dynamically based on the first combobox. So, I mean to say that they are related to each other. I will really appreciate the help.

                C++Prog

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #7

                Why it doesnt work?


                WhiteSky


                C 1 Reply Last reply
                0
                • H Hamid Taebi

                  Why it doesnt work?


                  WhiteSky


                  C Offline
                  C Offline
                  celllllllll
                  wrote on last edited by
                  #8

                  I dunno know why it doesn't work. int nToken = m_Aux.GetCurSel(); if (nToken == V) { m_C.EnableWindow(FALSE); m_Spin.SetRange(0,1000); } else { m_C.EnableWindow(TRUE); } m_Au.SetCurSel(0); The code is disabling the complete second combobox but I wanted to disable it for V only. Don't know what to do Thanks

                  C++Prog

                  H 1 Reply Last reply
                  0
                  • C celllllllll

                    I dunno know why it doesn't work. int nToken = m_Aux.GetCurSel(); if (nToken == V) { m_C.EnableWindow(FALSE); m_Spin.SetRange(0,1000); } else { m_C.EnableWindow(TRUE); } m_Au.SetCurSel(0); The code is disabling the complete second combobox but I wanted to disable it for V only. Don't know what to do Thanks

                    C++Prog

                    H Offline
                    H Offline
                    Hamid Taebi
                    wrote on last edited by
                    #9

                    Whats return value of EnableWindow for second combobox


                    WhiteSky


                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups