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. Comboboxex Editbox limit

Comboboxex Editbox limit

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
6 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
    ClickHeRe
    wrote on last edited by
    #1

    Hello, Does anyone know how to have the character limit on the editbox of a comboboxex control removed or set very big ? Thanks David

    D A 2 Replies Last reply
    0
    • C ClickHeRe

      Hello, Does anyone know how to have the character limit on the editbox of a comboboxex control removed or set very big ? Thanks David

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Use CComboBox::LimitText().


      "Take only what you need and leave the land as you found it." - Native American Proverb

      1 Reply Last reply
      0
      • C ClickHeRe

        Hello, Does anyone know how to have the character limit on the editbox of a comboboxex control removed or set very big ? Thanks David

        A Offline
        A Offline
        Aamir Butt
        wrote on last edited by
        #3

        I guess you need to make your combo box hold text more than its width. You can do this by setting CBS_AUTOHSCROLL style of the combo box. You can do this by setting Auto property of combobox to true.

        C 1 Reply Last reply
        0
        • A Aamir Butt

          I guess you need to make your combo box hold text more than its width. You can do this by setting CBS_AUTOHSCROLL style of the combo box. You can do this by setting Auto property of combobox to true.

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

          Sorry to say this but neither works As a test I wrote the following to see the limits and set the good styles: HWND hwndcombo = FindWindowEx( this->m_Hwnd, NULL, NULL, NULL ); SetWindowLong( hwndcombo, GWL_STYLE, GetWindowLong( hwndcombo, GWL_STYLE ) | CBS_AUTOHSCROLL ); int n = SendMessage( this->m_EditHwnd, EM_GETLIMITTEXT, 0, 0 ); char data[500]; wsprintf( data, "Limit : %d", n ); mIRCError( data ); SendMessage( hwndcombo, CB_LIMITTEXT, (WPARAM) 0, (LPARAM) 0 ); n = SendMessage( this->m_EditHwnd, EM_GETLIMITTEXT, 0, 0 ); wsprintf( data, "Limit : %d", n ); mIRCError( data ); Edit_LimitText( this->m_EditHwnd, 0 ); n = SendMessage( this->m_EditHwnd, EM_GETLIMITTEXT, 0, 0 ); wsprintf( data, "Limit : %d", n ); mIRCError( data ); The combo child of the comboboxex has its CBS_AUTOHSCROLL style, and the edit has its EM_AUTOHSCROLL style and the output of the above gives : Limit : 30000 Limit : 30000 Limit : 2147483646 So the initial limit is already 30000 chars so it isn't the culprit. I still hear the little ding sound when I get to the end of the editbox notifying I can't put more there even if the AutoHScroll style is there and the limit is way beyond the actual control limit.

          D 1 Reply Last reply
          0
          • C ClickHeRe

            Sorry to say this but neither works As a test I wrote the following to see the limits and set the good styles: HWND hwndcombo = FindWindowEx( this->m_Hwnd, NULL, NULL, NULL ); SetWindowLong( hwndcombo, GWL_STYLE, GetWindowLong( hwndcombo, GWL_STYLE ) | CBS_AUTOHSCROLL ); int n = SendMessage( this->m_EditHwnd, EM_GETLIMITTEXT, 0, 0 ); char data[500]; wsprintf( data, "Limit : %d", n ); mIRCError( data ); SendMessage( hwndcombo, CB_LIMITTEXT, (WPARAM) 0, (LPARAM) 0 ); n = SendMessage( this->m_EditHwnd, EM_GETLIMITTEXT, 0, 0 ); wsprintf( data, "Limit : %d", n ); mIRCError( data ); Edit_LimitText( this->m_EditHwnd, 0 ); n = SendMessage( this->m_EditHwnd, EM_GETLIMITTEXT, 0, 0 ); wsprintf( data, "Limit : %d", n ); mIRCError( data ); The combo child of the comboboxex has its CBS_AUTOHSCROLL style, and the edit has its EM_AUTOHSCROLL style and the output of the above gives : Limit : 30000 Limit : 30000 Limit : 2147483646 So the initial limit is already 30000 chars so it isn't the culprit. I still hear the little ding sound when I get to the end of the editbox notifying I can't put more there even if the AutoHScroll style is there and the limit is way beyond the actual control limit.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            ClickHeRe wrote:

            SetWindowLong( hwndcombo, GWL_STYLE, GetWindowLong( hwndcombo, GWL_STYLE ) | CBS_AUTOHSCROLL );

            Why not set this style at design time? Many styles cannot be changed at run time.

            ClickHeRe wrote:

            Edit_LimitText( this->m_EditHwnd, 0 );

            Why are you sending a message to the edit control? You should be using CComboBox::LimitText() instead?

            ClickHeRe wrote:

            I still hear the little ding sound when I get to the end of the editbox notifying I can't put more there even if the AutoHScroll style is there and the limit is way beyond the actual control limit.

            The CB_LIMITTEXT message limits only the text the user can enter. It has no effect on any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control when a string in the list box is selected.


            "Take only what you need and leave the land as you found it." - Native American Proverb

            C 1 Reply Last reply
            0
            • D David Crow

              ClickHeRe wrote:

              SetWindowLong( hwndcombo, GWL_STYLE, GetWindowLong( hwndcombo, GWL_STYLE ) | CBS_AUTOHSCROLL );

              Why not set this style at design time? Many styles cannot be changed at run time.

              ClickHeRe wrote:

              Edit_LimitText( this->m_EditHwnd, 0 );

              Why are you sending a message to the edit control? You should be using CComboBox::LimitText() instead?

              ClickHeRe wrote:

              I still hear the little ding sound when I get to the end of the editbox notifying I can't put more there even if the AutoHScroll style is there and the limit is way beyond the actual control limit.

              The CB_LIMITTEXT message limits only the text the user can enter. It has no effect on any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control when a string in the list box is selected.


              "Take only what you need and leave the land as you found it." - Native American Proverb

              C Offline
              C Offline
              ClickHeRe
              wrote on last edited by
              #6

              Good point, must I say that MSDN help sucks then ComboBoxEx Control Styles ComboBoxEx controls support only the following ComboBox styles: CBS_SIMPLE CBS_DROPDOWN CBS_DROPDOWNLIST WS_CHILD No where does it say it supports in the CreateWindow() CBS_AUTOHSCROLL Anyways, fixed, thanks

              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