Autor Beitrag
Stefan Z.
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Fr 16.05.03 16:08 
Hallo zusammen,
Ich versuche seit Stunden das Umwandeln von Umlauten zu realisieren, schaffe es aber nicht !!!

Was will ich:
Wen ich in einem Eingabefeld (Memo,Edit) z.B die Taste 'ä' drücke, so soll 'ae' zurückgegeben werden.

Wenn es um einzelne Zeichen geht, ist das ja kein Problem, dann nutze ich das OnKeyPress Ereignis. Aber 'ae' ist ja leider klein char, sonder ein string und das funzt leider nicht :evil:
Kann mir jemand helfen, wäre super nett, :lol:
Stefan
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Fr 16.05.03 16:14 
wir hatten hier erst kürzlich ein topic über stringreplace. such mal danach da kannst du sachen in einem string durch einen adren erstezten. das einfach in das onChange des Edits rein und feddich !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Stefan Z. Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Fr 16.05.03 16:25 
ahhh, ich verstehe, was gemeint ist, werd mal nach dem Post suchen, danke, schonmal, manchmal ist es echt einfacher, wie man denk, :lol:

Danke,
Stefan
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Fr 16.05.03 19:00 
kein problem. immer wieder gern

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 16.05.03 19:03 
Oder so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
 if key = 'ä' then
 begin
   Edit1.Text:=Edit1.Text+'ae';
   key:=#0;
   Edit1.SelStart:=Length(edit1.Text);
 end;
end;

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Fr 16.05.03 19:05 
ist aber umständlicher als stringreplace !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 16.05.03 19:08 
Ich kenne die Methode mit dem StringReplace nicht. Bei welchem Ereignis wird das denn aufgerufen? Edit1.Text muss ja dann schon gesetzt worden sein, oder?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 17.05.03 11:51 
ja das muss sie. du müsstest die also im OnChange aufrufen !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 17.05.03 11:57 
Hm, ich denke, das ist nicht so optimal. Zum einen finde ich, dass eine solche Ersetzung intuitiv eher in das OnKeyPress-Ereignis passt. Dort würde ich zumindest zuerst danach suchen. Zum anderen ist es nicht sehr performant, wenn man mit StringReplace arbeitet, da dann jedesmal der gesamte String durchsucht wird.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 17.05.03 12:01 
na ja jetzt komm aber. das bisschen string, das in so einem Edit drin ist.... das wird die performance ja nicht grad in die knie zwingen oder ?

bei nem memo würd ich deine variante nehmen.

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 17.05.03 12:49 
Bei einem Edit mag es wirklich kaum einen Unterschied machen (und gar keinen, den ein Mensch wahrnehmen könnte). Aber ich finde, es ist eine unsaubere Programmierweise, wenn man nicht immer den optimalen Weg geht.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: So 18.05.03 11:32 
nja ok. hast schon recht.

_________________
In the beginning was the word.
And the word was content-type: text/plain.