Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Auto filter Combo box

CrISCoderCrISCoder Member Posts: 4
I need to implement a VC++ combo box that allows the user to type in the edit portion of the box, and automatically searches to the first entry in the list with the character typed. I want to do this for however many characters are typed. The only examples I can find are for DHTLM pages. I need to use this for a combo box on a dialog.
Any ideas?

Comments

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : I need to implement a VC++ combo box that allows the user to type in the edit portion of the box, and automatically searches to the first entry in the list with the character typed. I want to do this for however many characters are typed. The only examples I can find are for DHTLM pages. I need to use this for a combo box on a dialog.
    : Any ideas?
    :
    [blue]Every time you type something in combo box editor you will receive 'CBN_EDITCHANGE'. Use 'CComboBox::FindString()' to see if the entry is in the list.[/blue]
  • CrISCoderCrISCoder Member Posts: 4
    : : I need to implement a VC++ combo box that allows the user to type in the edit portion of the box, and automatically searches to the first entry in the list with the character typed. I want to do this for however many characters are typed. The only examples I can find are for DHTLM pages. I need to use this for a combo box on a dialog.
    : : Any ideas?
    : :
    : [blue]Every time you type something in combo box editor you will receive 'CBN_EDITCHANGE'. Use 'CComboBox::FindString()' to see if the entry is in the list.[/blue]
    : :
    : [red]I managed to get that far. I believe I have it working except that it doesn't allow character deletion using the delete or backspace keys. Here's the code in my CBN_EDITCHANGE event...[/red]
    [size=1][code]
    void CommanderWindowDlg::onTypedCommand()
    {
    CString stringToFind = "";
    int selIndex = 0;
    static int prevIndex = 0;
    int numCharsTyped = 0;
    int selectRemainder = 0;

    //Get text from the edit portion of the combo box
    cmdSelect.GetWindowText(stringToFind);
    numCharsTyped = stringToFind.GetLength();
    //Copy entry to editbox if found
    selIndex = cmdSelect.SelectString(-1, stringToFind);

    if(selIndex != CB_ERR)
    {
    //Select only the characters AFTER what was typed by the user
    cmdSelect.SetEditSel(numCharsTyped, -1);
    prevIndex = selIndex;
    }
    else
    {
    //Not found so set selection back to previous
    cmdSelect.SetCurSel(prevIndex);
    //Select only the characters AFTER what was typed by the user
    cmdSelect.SetEditSel(numCharsTyped - 1, -1);
    }
    }[/code][/size]

  • Chris BrownChris Brown USAMember Posts: 4,496 ✭✭

    ______ [ http://forcoder.org ] free ebooks and video tutorials about / PL/SQL, C, Swift, PHP, Java, Scratch, C++, JavaScript, R, Go, Perl, Delphi, Visual Basic, MATLAB, Visual Basic .NET, Objective-C, Python, Assembly, C#, Ruby ML, F#, Crystal, Erlang, Rust, Scheme, ABAP, Transact-SQL, Lisp, Apex, D, Bash, Alice, LabVIEW, Awk, Fortran, Ada, Lua, Kotlin, FoxPro, COBOL, SAS, VBScript, Clojure, Prolog, Julia, Scala, Hack, Logo, Dart / ______

Sign In or Register to comment.