[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

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???
0
GGriffith
Asked:
GGriffith
  • 2
1 Solution
 
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
 
intheCommented:
well you learn something everyday .. ;-)
0
 
GGriffithAuthor Commented:
Thank you very much
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now