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. How to disable the dropdown arrow of a combo box?

How to disable the dropdown arrow of a combo box?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
6 Posts 5 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.
  • B Offline
    B Offline
    bin8922
    wrote on last edited by
    #1

    Hello, there, I am currently working on a project. There is a combo box. I'd like to know how I can disable the dropdown arrow of it or hide the dropdown arrow. In my project there is two setting, one is keeping the input history, one is not keeping the input history. I tried m_Combo.ShowDropDown(false)when not keeping the history, but there is a black line under it and it doesn't look good. Is there a way to solve this problem? Thanks a lot in advance. Bin

    S M 2 Replies Last reply
    0
    • B bin8922

      Hello, there, I am currently working on a project. There is a combo box. I'd like to know how I can disable the dropdown arrow of it or hide the dropdown arrow. In my project there is two setting, one is keeping the input history, one is not keeping the input history. I tried m_Combo.ShowDropDown(false)when not keeping the history, but there is a black line under it and it doesn't look good. Is there a way to solve this problem? Thanks a lot in advance. Bin

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      One way is to subclass the control, and handle WM_LBUTTONDOWN yourself, to effectively disable it that way, or alternatively, at run-time create an edit control in it's place which is ES_READONLY. Steve S

      1 Reply Last reply
      0
      • B bin8922

        Hello, there, I am currently working on a project. There is a combo box. I'd like to know how I can disable the dropdown arrow of it or hide the dropdown arrow. In my project there is two setting, one is keeping the input history, one is not keeping the input history. I tried m_Combo.ShowDropDown(false)when not keeping the history, but there is a black line under it and it doesn't look good. Is there a way to solve this problem? Thanks a lot in advance. Bin

        M Offline
        M Offline
        MeterMan
        wrote on last edited by
        #3

        If your wanting to disable it do this have a combo box and give it a control name like m_example then on your button or whatever your using lets say your using a button and the button is called History you put under OnHistory() m_example.EnableWindow(FALSE); // disabled combobox or whatever linked to m_example.EnableWindow(TRUE); // enables combobox or whatever linked to now if you wanna hide it all together i would do this under the OnHistory() m_example.ShowWindow(SW_HIDE); // hides the combobox or whatever linked to if you want the window back then m_example.ShowWindow(SW_SHOW);// shows the combobox or whatever linked to GOOD LUCK, HOPE THIS HELPS. Win32newb "Making windows programs worse than they already are"

        B 1 Reply Last reply
        0
        • M MeterMan

          If your wanting to disable it do this have a combo box and give it a control name like m_example then on your button or whatever your using lets say your using a button and the button is called History you put under OnHistory() m_example.EnableWindow(FALSE); // disabled combobox or whatever linked to m_example.EnableWindow(TRUE); // enables combobox or whatever linked to now if you wanna hide it all together i would do this under the OnHistory() m_example.ShowWindow(SW_HIDE); // hides the combobox or whatever linked to if you want the window back then m_example.ShowWindow(SW_SHOW);// shows the combobox or whatever linked to GOOD LUCK, HOPE THIS HELPS. Win32newb "Making windows programs worse than they already are"

          B Offline
          B Offline
          bin8922
          wrote on last edited by
          #4

          thanks a lot. But I just want to disable the drop down button and make it work as an edit box. I don't want to disable the whole thing. Thanks.

          B 1 Reply Last reply
          0
          • B bin8922

            thanks a lot. But I just want to disable the drop down button and make it work as an edit box. I don't want to disable the whole thing. Thanks.

            B Offline
            B Offline
            Babu_Abdulsalam
            wrote on last edited by
            #5

            what you can do is: Just iterate the windows of the combo box. Combo box contains the edit box and the button. For example char szClassName[256]; CWnd* pWnd=(CWnd *)m_combo.GetWindow(GW_CHILD); ::GetClassName(pWnd->GetSafeHwnd(), szClassName, 256); while( strcmp( szClassName,_T("Button")) != 0 ) { pWnd=(CWnd *)m_combo.GetWindow(GW_HWNDNEXT); } //Got the button if( pWnd ) pWnd->ShowWindow( SW_HIDE );

            R 1 Reply Last reply
            0
            • B Babu_Abdulsalam

              what you can do is: Just iterate the windows of the combo box. Combo box contains the edit box and the button. For example char szClassName[256]; CWnd* pWnd=(CWnd *)m_combo.GetWindow(GW_CHILD); ::GetClassName(pWnd->GetSafeHwnd(), szClassName, 256); while( strcmp( szClassName,_T("Button")) != 0 ) { pWnd=(CWnd *)m_combo.GetWindow(GW_HWNDNEXT); } //Got the button if( pWnd ) pWnd->ShowWindow( SW_HIDE );

              R Offline
              R Offline
              rgaab
              wrote on last edited by
              #6

              Thanks alot, very helpful hint!! :thumbsup:

              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