Solved

EditBox with history

Posted on 2003-11-02
8
345 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

23 Experts available now in Live!

Get 1:1 Help Now