Solved

EditBox with history

Posted on 2003-11-02
8
344 Views
Last Modified: 2010-05-18
I wish to add to my edit box history features. How can I do as when I type couple characters to propose a possible full word ( as IE URL history ).
0
Comment
Question by:ginsonic
8 Comments
 

Expert Comment

by:wwwbetyar
Comment Utility
Hi.

Use lookupcombobox !
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
from my paq using a combobox:

Function ReturnIndex(Fragment : String; Strings : TStrings) : Integer;
var I : Integer;
begin
 I := 0;
 while (I < Strings.Count) and
       (pos(Fragment,Strings[I]) <> 1) do inc(i);
 if I = Strings.Count then I := -1;
 result := i;
end;

procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
var
 I : Integer;
 J : Integer;
 S : String;
begin
 if not (Key in [#8,#13]) then
 begin
   J := ComboBox1.SelStart;
   S := copy(ComboBox1.Text,1,J)+key;
   I := ReturnIndex(S,ComboBox1.Items);
   if I > -1 then
   begin
     ComboBox1.Text := ComboBox1.Items[i];
     ComboBox1.SelStart := J+1;
     ComboBox1.SelLength := length(ComboBox1.Text)-J;
   end
   else
   begin
     ComboBox1.Text := s;
     ComboBox1.SelStart := J+1;
     ComboBox1.SelLength := 0;
   end;
   Key := #0;
 end;
end;

meikl ;-)
0
 
LVL 9

Author Comment

by:ginsonic
Comment Utility
Not success :(
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
whats missed?

for CaseIntensitve replace this

Function ReturnIndex(Fragment : String; Strings : TStrings) : Integer;
var I : Integer;
begin
 I := 0;
 while (I < Strings.Count) and
       (pos(Fragment,Strings[I]) <> 1) do inc(i);
 if I = Strings.Count then I := -1;
 result := i;
end;

with this

Function ReturnIndex(Fragment : String; Strings : TStrings) : Integer;
var I : Integer;
begin
 I := 0;
 while (I < Strings.Count) and
       (pos(UpperCase(Fragment),UpperCase(Strings[I])) <> 1) do inc(i);
 if I = Strings.Count then I := -1;
 result := i;
end;

for learning new Compareable values use

procedure TForm1.ComboBox1KeyPress(Sender: TObject; var Key: Char);
var
 I : Integer;
 J : Integer;
 S : String;
begin
 if not (Key in [#8]) then
 begin
   J := ComboBox1.SelStart;
   S := copy(ComboBox1.Text,1,J)+key;
   I := ReturnIndex(S,ComboBox1.Items);
   if (key = #13) and (i = -1) then  //learn on enter
     ComboBox1.Items.add(ComboBox1.text)
   else
   begin
     if I > -1 then
     begin
       ComboBox1.Text := ComboBox1.Items[i];
       ComboBox1.SelStart := J+1;
       ComboBox1.SelLength := length(ComboBox1.Text)-J;
     end
     else
     begin
       ComboBox1.Text := s;
       ComboBox1.SelStart := J+1;
       ComboBox1.SelLength := 0;
     end;
     Key := #0;
   end;
 end;
end;

meikl ;-)
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 9

Author Comment

by:ginsonic
Comment Utility
Found on net a 'SuggestEdit' box component. It save the typed words to a file and use this dictionary every time after that. Exactly what I need.

SuggestEdit v.1.0
http://www.torry.net/edits_enh.htm

Thanks to all for help.
0
 
LVL 9

Author Comment

by:ginsonic
Comment Utility
I have a problem with VCL. On my system ( XP Prof ) all work perfect. But when I try to run my application to my client who use a Win98 Second Edition the application give an error message ( I/O error ).

The problem come from this VCL ( I try a simple app with just this edit box inside ). Look alike is a problem when try to load the' dictionary'. If somebody can help me to modify a version that will support early Win OS version I will give this points and anothers 500 points for bug fix.

Thanks in advance,
Nick

P.S. I don't have a Win98 license so I can't locate the bug :(
0
 
LVL 8

Accepted Solution

by:
RickJ earned 500 total points
Comment Utility
In SuggEdit.pas search for the line

dir := GetCurrentDir + '\' + ExtractFileName(dicPath);

remove the '\'

i.e dir := GetCurrentDir + ExtractFileName(dicPath);

This should work fine.
0
 
LVL 9

Author Comment

by:ginsonic
Comment Utility
I found myself this bug in add procecedure too. But in this case will don't work for XP.

I think that GetCurrentDir return in Win9x the path with '\' at end and without in NT,XP.

I intend to detect the last char for GetCurrentDir. If is '\' then I will remove else ...

Anyway the points are yours. Thanks for support!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now