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 provent text selection in CComboBox ?

How to provent text selection in CComboBox ?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
4 Posts 2 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.
  • M Offline
    M Offline
    mesajflaviu
    wrote on last edited by
    #1

    I have an CComboBoxExt derived from CCOmboBox .. but I have an small problem , perhaps you can help me :

    CComboBoxExt	m\_Combo;
    

    void CTestComboView::OnInitialUpdate()
    {
    CFormView::OnInitialUpdate();
    GetParentFrame()->RecalcLayout();
    ResizeParentToFit();

    m\_Combo.AddString("One");
    m\_Combo.AddString("Two");
    m\_Combo.AddString("Three");
    

    }

    and when I type 'O' in combobox , it select me automatically 'One' item from the list ... well , I try this one :

    void CComboBoxExt::OnEditupdate()
    {
    // TODO: Add your control notification handler code here

    CString sText;
    GetWindowText(sText);
    DWORD dwCurSel = GetEditSel();
    WORD dStart = LOWORD(dwCurSel);
    WORD dEnd = HIWORD(dwCurSel);
    if(dStart == 0 && dEnd == sText.GetLength())
    	SetEditSel(sText.GetLength(),sText.GetLength());
    

    }

    but have no effect ....

    M D 2 Replies Last reply
    0
    • M mesajflaviu

      I have an CComboBoxExt derived from CCOmboBox .. but I have an small problem , perhaps you can help me :

      CComboBoxExt	m\_Combo;
      

      void CTestComboView::OnInitialUpdate()
      {
      CFormView::OnInitialUpdate();
      GetParentFrame()->RecalcLayout();
      ResizeParentToFit();

      m\_Combo.AddString("One");
      m\_Combo.AddString("Two");
      m\_Combo.AddString("Three");
      

      }

      and when I type 'O' in combobox , it select me automatically 'One' item from the list ... well , I try this one :

      void CComboBoxExt::OnEditupdate()
      {
      // TODO: Add your control notification handler code here

      CString sText;
      GetWindowText(sText);
      DWORD dwCurSel = GetEditSel();
      WORD dStart = LOWORD(dwCurSel);
      WORD dEnd = HIWORD(dwCurSel);
      if(dStart == 0 && dEnd == sText.GetLength())
      	SetEditSel(sText.GetLength(),sText.GetLength());
      

      }

      but have no effect ....

      M Offline
      M Offline
      mesajflaviu
      wrote on last edited by
      #2

      I forget to say something : I use this , may me this cause weird behaviour ?

      void CComboBoxExt::OnEditchange()
      {
      // TODO: Add your control notification handler code here

      CString sText;
      GetWindowText(sText);
      if(sText.IsEmpty())ShowDropDown(FALSE);
      else ShowDropDown();
      

      }

      1 Reply Last reply
      0
      • M mesajflaviu

        I have an CComboBoxExt derived from CCOmboBox .. but I have an small problem , perhaps you can help me :

        CComboBoxExt	m\_Combo;
        

        void CTestComboView::OnInitialUpdate()
        {
        CFormView::OnInitialUpdate();
        GetParentFrame()->RecalcLayout();
        ResizeParentToFit();

        m\_Combo.AddString("One");
        m\_Combo.AddString("Two");
        m\_Combo.AddString("Three");
        

        }

        and when I type 'O' in combobox , it select me automatically 'One' item from the list ... well , I try this one :

        void CComboBoxExt::OnEditupdate()
        {
        // TODO: Add your control notification handler code here

        CString sText;
        GetWindowText(sText);
        DWORD dwCurSel = GetEditSel();
        WORD dStart = LOWORD(dwCurSel);
        WORD dEnd = HIWORD(dwCurSel);
        if(dStart == 0 && dEnd == sText.GetLength())
        	SetEditSel(sText.GetLength(),sText.GetLength());
        

        }

        but have no effect ....

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

        mesajflaviu wrote:

        ...but I have an small problem...

        Which is? :confused: You've shown code, but have failed to explain what is supposed to happen vs. what is actually happening.

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Man who follows car will be exhausted." - Confucius

        M 1 Reply Last reply
        0
        • D David Crow

          mesajflaviu wrote:

          ...but I have an small problem...

          Which is? :confused: You've shown code, but have failed to explain what is supposed to happen vs. what is actually happening.

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Man who follows car will be exhausted." - Confucius

          M Offline
          M Offline
          mesajflaviu
          wrote on last edited by
          #4

          The problem is that when I type 'O' , the control autocompletion 'One' in editbox , select all text and put the mouse cursor at the end of the 'One' string .. is annoynig , because I want to type myself all string ... for more details , I put here[^] an source code .. .just type 'O' in combobox ....

          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