Autor Beitrag
florida
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

Windows 7 Home Premium, Windows XP Professional, Windows 2000
Delphi 2010 Architect
BeitragVerfasst: Do 12.05.11 18:30 
Bei der VCL ist es das "leichteste" auf der Welt, eine Edit-Abfrage zumachen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
if Edit1.Text='Probe'
begin
...
end;


Wie kann ich so eine Schleife eigentlich ohne VCL, sondern mit dem reinen Windows SDK realisieren?
FrEaKY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 235


D7
BeitragVerfasst: Do 12.05.11 18:33 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
int GetWindowText(

    HWND hWnd,  // handle of window or control with text
    LPTSTR lpString,  // address of buffer for text
    int nMaxCount   // maximum number of characters to copy
   );
florida Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 137

Windows 7 Home Premium, Windows XP Professional, Windows 2000
Delphi 2010 Architect
BeitragVerfasst: Do 12.05.11 18:46 
Soweit bin ich auch schon gekommen, aber wie kann ich einen Text vergleichen?

Wenn ich sage:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
if buffer = "Probe"
begin
...
end;

... funktioniert die if-Schleife nicht.

Hier habe ich mal ein kleines C++-Beispiel (funktioniert genauso wenig):
ausblenden Quelltext
1:
2:
3:
4:
5:
    char *buffer = new char[Edit_GetTextLength(Edit1->Handle) + 1];
    SendMessage(Edit1->Handle, WM_GETTEXT, 64, (long)buffer);
    if (buffer == "Edit1") {
      MessageBox(Handle, buffer, buffer, 0);
    }
FrEaKY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 235


D7
BeitragVerfasst: Do 12.05.11 19:24 
Z.B. so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var
    p: PChar;
    i: integer;
begin
    i := GetWindowTextLength(Edit1.Handle)+1;
    GetMem(p, i);
    GetWindowText(Edit1.handle, p, i);
    if p='Probe' then
      ShowMessage(p);
    FreeMem(p, i);


Edit:
So kannst du es auch machen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
    s: string;
    i: integer;
begin
    i := GetWindowTextLength(Edit1.Handle);
    SetLength(s, i);
    GetWindowText(Edit1.handle, PChar(s), i+1);
    if s = 'Probe' then
      ShowMessage(s);

Ist vielleucht bequemer ohne PChars.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 12.05.11 20:41 
user profile iconflorida hat folgendes geschrieben Zum zitierten Posting springen:
... funktioniert die if-Schleife nicht.
Wo siehst du da eine Schleife?
if-schleife.de/
FrEaKY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 235


D7
BeitragVerfasst: Do 12.05.11 23:40 
Zitat:

if-schleife.de/

:lol:

Dafür mietet extra jemand eine Domain. Muss ja ein beliebter Fehler sein :shock:
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19315
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 12.05.11 23:45 
user profile iconFrEaKY hat folgendes geschrieben Zum zitierten Posting springen:
Dafür mietet extra jemand eine Domain. Muss ja ein beliebter Fehler sein :shock:
Ja, leider wissen offenbar relativ viele Programmieranfänger auch nach einer Weile programmieren nicht was eine Schleife ist. :nixweiss:
Bei den Preisen für eine Domain stört so eine zusätzliche Domain wenig, ich habe auch mehrere Domains. ;-)