Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to replace characters while typing Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
18-May-03
Category
System
Language
Delphi 3.x
Views
94
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Attila Torda-Pilisi

Replace chracters while typing

This code allows you to replaces umlauts (i.e. '', '', etc.)  with 'ae', 'oe', 
etc. while typing.

Answer:
1   
2   procedure TForm1.AppOnMessage(var Msg: TMsg; var Handled: Boolean);
3   type
4     TReplacement = record
5       chIn: Char;
6       chOut: string[2]
7     end;
8     TReplacements = array[0..6] of TReplacement;
9   const
10    Replacements: TReplacements = ((chIn: ''; chOut: 'ae'),
11      (chIn: ''; chOut: 'oe'),
12      (chIn: ''; chOut: 'ue'),
13      (chIn: ''; chOut: 'Ae'),
14      (chIn: ''; chOut: 'Oe'),
15      (chIn: ''; chOut: 'Ue'),
16      (chIn: ''; chOut: 'ss'));
17  var
18    i: Integer;
19    c: Char;
20  begin
21    Handled := False;
22    if Msg.message = WM_CHAR then
23    begin
24      if Chr(Msg.wParam) in ['', '', '', '', '', '', ''] then
25      begin
26        for i := Low(Replacements) to High(Replacements) do
27          if Chr(Msg.wParam) = Replacements[i].chIn then
28          begin
29            Msg.wParam := Ord(Replacements[i].chOut[1]);
30            with Longrec(Msg.lParam) do
31              Hi := (Hi and $FF00) or VKKeyScan(Replacements[i].chOut[2]);
32            PostMessage(Msg.hwnd, WM_CHAR, Ord(Replacements[i].chOut[2]),
33              Msg.wParam);
34            with Longrec(Msg.lParam) do
35              Hi := (Hi and $FF00) or VKKeyScan(Char(Msg.wParam));
36            Break;
37          end;
38      end;
39    end;
40  end;
41  
42  procedure TForm1.FormCreate(Sender: TObject);
43  begin
44    Application.OnMessage := AppOnMessage;
45  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC