CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2002
    Posts
    124

    slow down timing between keypresses

    Is there anyway to slow down the timing between keypresses in a ListBox ?I am using VC++ 2008?

    I am referring to the autofind feature where a file is selected based on the keys pressed on the keyboard.

    If you type fast enough you can select a file that starts with specific characters. But if you slow down, the next key pressed will start a new find for that key.

    thanks...

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: slow down timing between keypresses

    Quote Originally Posted by robertpantangco View Post
    Is there anyway to slow down the timing between keypresses in a ListBox ?I am using VC++ 2008?

    I am referring to the autofind feature where a file is selected based on the keys pressed on the keyboard.

    If you type fast enough you can select a file that starts with specific characters. But if you slow down, the next key pressed will start a new find for that key.

    thanks...
    So let me understand what you're saying:

    I'm typing in a name and then decide I need to get up out of my chair and stretch. Now I sit back down, and then finish typing. Are you saying that your control has erased what I previously typed in?

    You think that is a good interface?

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Apr 2002
    Posts
    124

    Re: slow down timing between keypresses

    Paul,

    Let us for example assume your list box is active and contains the following entries (just as if you are in Windows Explorer):

    Advertising.txt
    Building.txt
    Butterfly.txt
    Dairyfarm.txt
    Fieldtest.txt
    Timeout.txt
    Zebra.txt

    If you key in the characters "but" quickly, Butterfly.txt will be selected by autofind. I am not sure what this feature is called in Windows. Others call this feature autocomplete.

    However, if you key in "bu" then hesitate for say 3 seconds, and type "t", Timeout.txt will now be selected.

    Your intent is to select Butterfly.txt initially but since you were a little slow in typing in the three characters "but" in succession the "t" caused Timeout.txt to be selected instead.

    Hope I explained this clearly enough.

    Thanks for the response.

  4. #4
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: slow down timing between keypresses

    This is standard Windows behavior, so I don't understand why you would like to change it.
    Changing it will confuse the users of your program.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  5. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: slow down timing between keypresses

    Quote Originally Posted by robertpantangco View Post
    Paul,

    Let us for example assume your list box is active and contains the following entries (just as if you are in Windows Explorer):

    Advertising.txt
    Building.txt
    Butterfly.txt
    Dairyfarm.txt
    Fieldtest.txt
    Timeout.txt
    Zebra.txt

    If you key in the characters "but" quickly, Butterfly.txt will be selected by autofind. I am not sure what this feature is called in Windows. Others call this feature autocomplete.

    However, if you key in "bu" then hesitate for say 3 seconds, and type "t", Timeout.txt will now be selected.
    What if there are 50 entries that are similar in the first 10 characters. Are you saying that if I type in 10 characters, took time to sneeze and wipe my nose, the next letter I type will erase what I already entered because I didn't enter a character in 3 seconds?

    Also, what if I'm a slow typist? Is this control going to jump letters around because I happen to type slowly?

    I'll ask you again -- given what I stated, does this sound like a good user interface to you? If anything, your users will be very frustrated with this.

    Regards,

    Paul McKenzie

  6. #6
    Join Date
    Apr 2002
    Posts
    124

    Re: slow down timing between keypresses

    Paul,
    As Marc said, this is standard Windows behavior which I do not want to change. I just want to slow down the timeout so that those who cannot type fast enough can still select the file they want.

    And I do not understand what you mean by erasing what has been previously entered. The user is not erasing anything!

    This is not a Text box that the user is entering text into.

    Go to Windows Explorer and open a folder with many files.

    If you key in, the first few letters of a filename, the file will be selected and highlighted!

    Marc G understands what I am talking about.

  7. #7
    Join Date
    Apr 1999
    Posts
    27,449

    Re: slow down timing between keypresses

    Quote Originally Posted by robertpantangco View Post
    Paul,
    As Marc said, this is standard Windows behavior which I do not want to change. I just want to slow down the timeout so that those who cannot type fast enough can still select the file they want.

    And I do not understand what you mean by erasing what has been previously entered. The user is not erasing anything!
    But according to your description, you are moving the first entry away from me if I happen to type slowly.

    Again, if there are 50 entries that have the first 10 letters the same, I type in the first 10 letters. The listbox is already close to where I want it to be, but I need to type more to narrow the search down. Then I take a rest for 3 seconds. With your version of what you want to do, what happens if I type another letter?

    Regards,

    Paul McKenzie

  8. #8
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: slow down timing between keypresses

    As said, this is a windows thing, and I'm not sure you can change it.
    Maybe you can emulate it yourself by catching keypresses and maybe by using LB_FINDSTRING.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  9. #9
    Join Date
    Apr 2002
    Posts
    124

    Re: slow down timing between keypresses

    To Paul,
    When you type in the next letter after the pause, the selection jumps to the first occurence of that letter in the list.

    In essence, you move out of the position you were able to narrow at using the first 10 letters and have to start anew.

    When the folder contains hundreds of filenames, this could be inconvenient.

  10. #10
    Join Date
    Apr 2002
    Posts
    124

    Re: slow down timing between keypresses

    To Marc G,
    LB_FINDSTRING might help.

    I am also thinking of including a "wait" or "sleep" after each OnKeyDown.

  11. #11
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: slow down timing between keypresses

    How will adding a wait or sleep help?
    It might things even worse.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured