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. Enabling and Diabling a Control

Enabling and Diabling a Control

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
5 Posts 3 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 have two ComboBox controls {A(it has items like A1, A2 and A3)and B (B has B1, B2 and B3)} and one spin control (Z). Now, my task is that when from control A, A1 is selected then full control B should be diabled. And for all others A2 and A3, B should get enabled. This is how my code is: m_CtrlA.SetCurSel(0); m_CtrlB.ResetContent(); if (m_CtrlA.GetCurSel() == A1) { m_CtrlB.EnableWindow(FALSE); m_Spin.SetRange(0,1000); } else { m_CtrlB.EnableWindow(TRUE); } So, the problem is what this code is doing is that it is disabling the full m_CtrlB for every case. But I want to disable it for A1 only. I would really appreciate if someone could help me. Thanks a lot in advance

    C++Prog

    J E 2 Replies Last reply
    0
    • C celllllllll

      Hi All, I have two ComboBox controls {A(it has items like A1, A2 and A3)and B (B has B1, B2 and B3)} and one spin control (Z). Now, my task is that when from control A, A1 is selected then full control B should be diabled. And for all others A2 and A3, B should get enabled. This is how my code is: m_CtrlA.SetCurSel(0); m_CtrlB.ResetContent(); if (m_CtrlA.GetCurSel() == A1) { m_CtrlB.EnableWindow(FALSE); m_Spin.SetRange(0,1000); } else { m_CtrlB.EnableWindow(TRUE); } So, the problem is what this code is doing is that it is disabling the full m_CtrlB for every case. But I want to disable it for A1 only. I would really appreciate if someone could help me. Thanks a lot in advance

      C++Prog

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

      Assuming, A1 is of type int and it's value is 0, you should remove m_CtrlA.SetCurSel(0);. because it sets the selection back to 0th item A1 and hence making the if condition useless.


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

      1 Reply Last reply
      0
      • C celllllllll

        Hi All, I have two ComboBox controls {A(it has items like A1, A2 and A3)and B (B has B1, B2 and B3)} and one spin control (Z). Now, my task is that when from control A, A1 is selected then full control B should be diabled. And for all others A2 and A3, B should get enabled. This is how my code is: m_CtrlA.SetCurSel(0); m_CtrlB.ResetContent(); if (m_CtrlA.GetCurSel() == A1) { m_CtrlB.EnableWindow(FALSE); m_Spin.SetRange(0,1000); } else { m_CtrlB.EnableWindow(TRUE); } So, the problem is what this code is doing is that it is disabling the full m_CtrlB for every case. But I want to disable it for A1 only. I would really appreciate if someone could help me. Thanks a lot in advance

        C++Prog

        J Offline
        J Offline
        jeron1
        wrote on last edited by
        #3

        In the if statement, A1 is used. What is A1 defined as? m_CtrlA.SetCurSel(0); m_CtrlB.ResetContent(); if (m_CtrlA.GetCurSel() == A1) if it's not 0 then this will never be equal, because you set the current selection to 0 before the if statement is executed.

        C 1 Reply Last reply
        0
        • J jeron1

          In the if statement, A1 is used. What is A1 defined as? m_CtrlA.SetCurSel(0); m_CtrlB.ResetContent(); if (m_CtrlA.GetCurSel() == A1) if it's not 0 then this will never be equal, because you set the current selection to 0 before the if statement is executed.

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

          Thanks for the quick response. A1 is define as: #define A1 (0) So, its value is Zero. And yes I should get rid of m_CtrlA.SetCurSel(0);

          C++Prog

          E 1 Reply Last reply
          0
          • C celllllllll

            Thanks for the quick response. A1 is define as: #define A1 (0) So, its value is Zero. And yes I should get rid of m_CtrlA.SetCurSel(0);

            C++Prog

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

            celllllllll wrote:

            And yes I should get rid of m_CtrlA.SetCurSel(0); C++Prog

            You should get rid of m_CtrlA.SetCurSel(0); and C++ Programming ? :rolleyes: :-D just kidding.


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

            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