Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 10-26-2005, 06:54 AM
kbboykin kbboykin is offline
Senior Member
 
Join Date: May 2005
Posts: 371
Default Autocomplete text using memo or richedit with a popup

Hello All,

I see from this post how to create an autocomplete list:
http://www.delphipages.com/threads/thread.cfm?ID=82590&G=82589

But what I want to do is to be able to insert phrases or select from a list of choices when I enter a special code in a memo or richedit. For example, if I type .NL the word normal is automatically written or if I type .PEEar would give me a popup (browse form with a list of choice that would get inserted).

Any one done this? or any one have any suggestions?

I would almost be like autotext in MSWord or autocomplete in IE, but more advanced.

Thanks in advance
--Keith
Reply With Quote
  #2  
Old 10-26-2005, 07:29 AM
mshkolnik mshkolnik is offline
Senior Member
 
Join Date: Jul 2001
Posts: 4,195
Default RE: Autocomplete text using memo or richedit with a popup

SynEdit have such feature (autocomplete like in Delphi IDE): http://SynEdit.SourceForge.net

With best regards, Mike Shkolnik
http://www.scalabium.com
Reply With Quote
  #3  
Old 10-26-2005, 07:35 AM
AceOmega AceOmega is offline
Senior Member
 
Join Date: Sep 2004
Posts: 2,393
Default RE: Autocomplete text using memo or richedit with a popup

In the OnChange event just do...

procedure TForm1.RichEdit1Change(Sender: TObject);
var
_NLpos : Integer;
_Original : String;
_Buffer : String;
begin
_Original := RichEdit1.Lines[RichEdit1.Lines.Count-1];
_NLpos := Pos('.NL',Uppercase(_Original));
_Buffer := _Original;
If _NLpos > 0 then
begin
While _NLpos > 0 do
begin
_Buffer := Copy(_Buffer,1,_NLpos-1) + 'normal '+
Copy(_Buffer,_NLpos+3,length(_Buffer));
_NLpos := Pos('.NL',Uppercase(_Buffer));
end;
RichEdit1.Lines[RichEdit1.Lines.Count-1] := _Buffer;
end;
end;
Reply With Quote
  #4  
Old 10-26-2005, 08:17 AM
kbboykin kbboykin is offline
Senior Member
 
Join Date: May 2005
Posts: 371
Default RE: Autocomplete text using memo or richedit with a popup

Thanks for you response, but this looks like it just works for an IDE. I want to use this in a project/app. Do you know if it would work there?

--Keith
Reply With Quote
  #5  
Old 10-26-2005, 08:20 AM
kbboykin kbboykin is offline
Senior Member
 
Join Date: May 2005
Posts: 371
Default RE: Autocomplete text using memo or richedit with a popup

Thanks

Haven't tested code yet, but this looks like it only works for the .NL, I would be using a table of words or a file of text, but want to "smarttext" it to autocomplete text. I guess I didn't make that clear.

I'll get back to you after I try your code snippet tonight or later this afternoon, if I get a chance.

--Keith
Reply With Quote
  #6  
Old 10-26-2005, 08:34 AM
AceOmega AceOmega is offline
Senior Member
 
Join Date: Sep 2004
Posts: 2,393
Default RE: Autocomplete text using memo or richedit with a popup

I am not going to write every thing for you just giving you an idea of how to use the OnChange event.
Reply With Quote
  #7  
Old 10-26-2005, 10:08 AM
kbboykin kbboykin is offline
Senior Member
 
Join Date: May 2005
Posts: 371
Default RE: Autocomplete text using memo or richedit with a popup

Now theres no need to be rude or terse. I never asked for code, just if this could be done. I am not a professional. Sorry to have even bothered.

--Keith
Reply With Quote
  #8  
Old 10-26-2005, 10:26 AM
AceOmega AceOmega is offline
Senior Member
 
Join Date: Sep 2004
Posts: 2,393
Default RE: Autocomplete text using memo or richedit with a popup

Sorry, I was not trying to be rude, I was explaining why the code was incomplete.
Reply With Quote
  #9  
Old 10-26-2005, 10:32 AM
kbboykin kbboykin is offline
Senior Member
 
Join Date: May 2005
Posts: 371
Default RE: Autocomplete text using memo or richedit with a popup

Thanks. Also your code does give me a good place to start, but I just didn't want to embark on something that others may know that it would be impossible to do.

I have learned so much from this forum and it is an excellent place for us non-professionals to get better.

Thanks.

--Keith
Reply With Quote
  #10  
Old 10-26-2005, 04:45 PM
kbboykin kbboykin is offline
Senior Member
 
Join Date: May 2005
Posts: 371
Default RE: Autocomplete text using memo or richedit with a popup

That works great, now I will try to expand on this snippet to use a table. I will let you know.

Thanks
--Keith
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 05:00 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.