Solved

EditBox with history

Posted on 2003-11-02
8
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Spellcheck in Webbrowser 1 76
Delphi - replicating a form 8 110
Delphi 2 89
How to Get Images From Server to Client using App Tethering 1 56
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

737 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