Solved

EditBox with history

Posted on 2003-11-02
8
347 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
ID: 9665621
Hi.

Use lookupcombobox !
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9665772
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
ID: 9666433
Not success :(
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 9666473
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
 
LVL 9

Author Comment

by:ginsonic
ID: 9668842
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
ID: 9679684
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
ID: 9744890
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
ID: 9745312
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…

685 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