whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

29 Visitors Online


 
...replace umlauts while typing?
Autor: P. Below
Homepage: http://www.teamb.com
[ Print tip ]  

Tip Rating (4):  
     


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

  Mit diesem Code kann man Umlautzeichen (ä, ö, ü usw.) durch
  ae, oe usw. ersetzen. Dies geschieht applikationsweit, während der Eingabe.
}

procedure TForm1.AppOnMessage(var Msg: TMsg; var Handled: Boolean);
type
  
TReplacement = record
    
chIn: Char;
    chOut: string[2]
  end;
  TReplacements = array [0..6] of TReplacement;
const
  
Replacements: TReplacements = ((chIn: 'ä'; chOut: 'ae'),
    (chIn: 'ö'; chOut: 'oe'),
    (chIn: 'ü'; chOut: 'ue'),
    (chIn: 'Ä'; chOut: 'Ae'),
    (chIn: 'Ö'; chOut: 'Oe'),
    (chIn: 'Ü'; chOut: 'Ue'),
    (chIn: 'ß'; chOut: 'ss'));
var
  
i: Integer;
  c: Char;
begin
  
Handled := False;
  if Msg.Message = WM_CHAR then
  begin
    if 
Chr(Msg.wParam) in ['ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', 'ß'] then
    begin
      for 
i := Low(Replacements) to High(Replacements) do
        if 
Chr(Msg.wParam) = Replacements[i].chIn then
        begin
          
Msg.wParam := Ord(Replacements[i].chOut[1]);
          with Longrec(Msg.lParam) do
            
Hi := (Hi and $FF00) or VKKeyScan(Replacements[i].chOut[2]);
          PostMessage(Msg.hwnd, WM_CHAR, Ord(Replacements[i].chOut[2]),
            Msg.wParam);
          with Longrec(Msg.lParam) do
            
Hi := (Hi and $FF00) or VKKeyScan(Char(Msg.wParam));
          Break;
        end;
    end;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  
Application.OnMessage := AppOnMessage;
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners