Solved

EditBox with history

Posted on 2003-11-02
8
346 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Connection between libmysql.dll and MySQL Versions 7 99
Magic Software info 18 132
tidtcpserver connection lost handle 2 88
firemonkey keyboard covers the controls 1 27
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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

825 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