Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Windows 10 1809 - Problem mit Memo.Text (https://www.delphipraxis.net/198118-windows-10-1809-problem-mit-memo-text.html)

Michael II 4. Okt 2018 20:35

Windows 10 1809 - Problem mit Memo.Text
 
Hallo Forum

Seit Windows 10 1809 (Build 17763) hängt ein Programm während mehreren Sekunden nach der Zuweisung

Delphi-Quellcode:
 Memo1.Text := Copy( Memo1.Text, 1, length( Memo1.Text )- 1 );
Umgeschrieben (Code unten) hängt das Programm bei der Zuweisung Memo1.Text := h;

Delphi-Quellcode:
  var h : TCaption;
begin
  h := Memo1.Text;
  h := Copy(h, 1, length(h) - 1);
  Memo1.Text := h;
Dieser Code hängt nicht:

Delphi-Quellcode:
  Memo1.Text := 'Hallo';
  h := Memo1.Text;
  h := Copy(h, 1, length(h) - 1);
  Memo1.Text := h;
Hat jemand ähnliche Erfahrungen gemacht? (Antworten wie: "Natürlich nicht, man macht das auch nicht so" sind willkommen :-D)

Auf allen anderen Windows Systemen XP, 7, Vista, Server 12, Server 16 ist's OK.

Gruss ins Forum
Michael

KodeZwerg 4. Okt 2018 20:41

AW: Windows 10 1809 - Problem mit Memo.Text
 
Was hat denn
Delphi-Quellcode:
Memo1.Text;
im ersten Beispiel für einen Wert? (eventuell Zeilenbrüche am Ende?)

Michael II 4. Okt 2018 20:52

AW: Windows 10 1809 - Problem mit Memo.Text
 
Hallo CodeZwerg

besten Dank für deine rasche Reaktion.

Antwort: Ja.

Der Code läuft in einem Chatfenster (User gibt Text ein und schliesst mit Return/Enter ab).

Im "Original" sieht der Code so aus und lief bis vor Windows 10 1809:

Delphi-Quellcode:
        if Memo2.Text <> '' then
        begin
          while CharInSet(Memo2.Text[length(Memo2.Text)], [#10, #13]) do
          begin
            Memo2.Text := Copy(Memo2.Text, 1, length(Memo2.Text) - 1);
            if Memo2.Text = '' then
              break;
          end;
        end;

Gruss
Michael

Michael II 4. Okt 2018 21:18

AW: Windows 10 1809 - Problem mit Memo.Text
 
Hallo CodeZwerg

Danke für deinen Hinweis.

Es ist wie du vermutest. Die Zuweisung

Delphi-Quellcode:
Memo1.Text := 'Hallo' + #13;
führt zum Problem.

Wenn ich #13#10 aufs Mal entferne, dann klappt's.

Offenbar sind frühere Windows Versionen "toleranter".

Gruss
Michael

KodeZwerg 4. Okt 2018 21:34

AW: Windows 10 1809 - Problem mit Memo.Text
 
Delphi-Quellcode:
function NoLineFeed(const s: string): string;
var i: integer;
begin
  result := s;
  for i := length(result) downto 1 do
    if ord(result[i])<32 then
      if (i>1) and (ord(result[i-1])<=32) then
        delete(result,i,1) else
        result[i] := ' ';
end;
Delphi-Quellcode:
  var h : TCaption;
begin
  h := NoLineFeed(Memo1.Text);
  h := Copy(h, 1, length(h) - 1);
  Memo1.Text := h;
Oder so :)
Gern geschehen und viel Spaß, Ps diese Funktion filtert alles unterhalb Ascii 32 raus und am ende ist es nur eine Zeile.

Eine Memo (Multiline-Edit) ist nicht so das wahre wenn ein Singleline das Ziel ist, vielleicht Control in ein Edit ändern?


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:43 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz