2007. június 21., csütörtök
Change keys pressed in a TMemo
Problem/Question/Abstract:
When you insert an accented letter into a HTML it should be converted into an extended code for international use.
That will help everyone who will build an HTML editor.
Answer:
Just add this to your memo keypress event:
procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
const
UnSup =
#171#187#193#225#194#226#198#230#192#197#229#195#227#196#228#199#231#162#169#20 +
#233#202#234#200#232#203#235#205#237#206#238#204#236#207#239#60#209#241#211#243 +
#212#244#210#242#216#248#213#245#214#246#34#174#223#218#250#219#251#217#249#220 +
#252#255;
Supported: array[0..61] of string =
(
'«', '»', 'Á', 'á',
'Â', 'â', 'Æ', 'æ',
'À', 'Å', 'å', 'Ã',
'ã', 'Ä', 'ä', 'Ç',
'ç', '¢', '©', 'É',
'é', 'Ê', 'ê', 'È',
'è', 'Ë', 'ë', 'Í',
'í', 'Î', 'î', 'Ì',
'ì', 'Ï', 'ï', '<',
'Ñ', 'ñ', 'Ó', 'ó',
'Ô', 'ô', 'Ò', 'ò',
'Ø', 'ø', 'Õ', 'õ',
'Ö', 'ö', '"', '®',
'ß', 'Ú', 'ú', 'Û',
'û', 'Ù', 'ù', 'Ü',
'ü', 'ÿ'
);
var
P: Integer;
begin
P := Pos(Key, UnSup);
if (P > 0) then
begin
Memo1.SetSelTextBuf(PChar(Supported[P - 1]));
Key := #0;
end;
end;
Obviously this can be ported to every type of char substitution.
If you really use it I raccomend that you insert into the array all special symbols!
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése