Searches In Dropdown boxes

I'm using a DBLookUpComboBox and on a certain client system when the user clicks in the box to get the drop down list and then starts typing in a value they want to look up it seems to do one letter at a time.

Example:  If they type in DRA it will go to the "D"s and then to the "R"s and finally to the "A"s instead of going to the closet value of "DRA"....I'm thinking its because they are on a slower network and the table they are using for the lookup has say a 100 records...It works fine on other lookups with less records...I guess I want to know is there a way to set the timing for the lookups in the boxes...Is it a Windows setting???
GGriffithAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
is it fast when not on network?
i mean can you install locally to test if it is the network that is the bottleneck ?

probably the slow network speed is the answer.maybe its possible doing this in seperate thread and setting prority to high value would help somethng like what getright does though im not sure how to implement it on a lookup .
 

var
  Pid : DWORD;
  Process : THandle;
  Thread : THandle;
 begin
  Pid := GetCurrentProcessID;
  Process := OpenProcess(PROCESS_SET_INFORMATION,false,Pid);
  SetPriorityClass(Process, REALTIME_PRIORITY_CLASS);
  Thread := GetCurrentThread;
  SetThreadPriority(Thread, THREAD_PRIORITY_TIME_CRITICAL);
 end;.
0
rwilson032697Commented:
There is a 2 second delay implemented in TDBLookupComboBox, if you want to change it you will need to do this: (change the 2000 below to a suitable number of milliseconds, or some variable you can allow the user to set):

Register this as a new component and use it instead of the vanilla one...

  TMyDBLookUpComboBox = class(TDBLookupControl);
    protected
      procedure ProcessSearchKey(Key: Char); override;
  end;

procedure TMyDBLookUpComboBox.ProcessSearchKey(Key: Char);
begin
var
  TickCount: Integer;
  S: string;
  CharMsg: TMsg;
begin
  if (FListField <> nil) and (FListField.FieldKind in [fkData, fkInternalCalc]) and
    (FListField.DataType in [ftString, ftWideString]) then
    case Key of
      #8, #27: SearchText := '';
      #32..#255:
        if CanModify then
        begin
          TickCount := GetTickCount;
          if TickCount - SearchTickCount > 2000 then SearchText := '';
          SearchTickCount := TickCount;
          if SysLocale.FarEast and (Key in LeadBytes) then
            if PeekMessage(CharMsg, Handle, WM_CHAR, WM_CHAR, PM_REMOVE) then
            begin
              if CharMsg.Message = WM_Quit then
              begin
                PostQuitMessage(CharMsg.wparam);
                Exit;
              end;
              SearchText := SearchText + Key;
              Key := Char(CharMsg.wParam);
            end;
          if Length(SearchText) < 32 then
          begin
            S := SearchText + Key;
            try
              if FListLink.DataSet.Locate(FListField.FieldName, S,
                [loCaseInsensitive, loPartialKey]) then
              begin
                SelectKeyValue(FKeyField.Value);
                SearchText := S;
              end;
            except
              { If you attempt to search for a string larger than what the field
                can hold, and exception will be raised.  Just trap it and
                reset the SearchText back to the old value. }
              SearchText := S;
            end;
          end;
        end;
    end;

end;

Cheers,

Raymond.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
intheCommented:
well you learn something everyday .. ;-)
0
GGriffithAuthor Commented:
Thank you very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.