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/)
-   -   Delphi FindwindowEx (https://www.delphipraxis.net/15627-findwindowex.html)

ReCoVeR 1. Feb 2004 19:07


FindwindowEx
 
huhu^^ ich will mit FindWindowEx einen string, in ein anderes fenster einfügen, doch in dem anderem fenster gibt es 4x TEdit....

Delphi-Quellcode:
var Handle: HWND;
    Eingabe: string;
begin
  Eingabe := 'alalalala';
  Handle := FindWindow('TForm1', nil);
  Handle := FindWindowEx(Handle,0,TEdit,nil);
  SendMessage(Handle,WM_SETTEXT,0,Integer(Eingabe));
geht dann nich.. weiß wer ne lösung?

Weiß net obs in die Kategorie gehört sorry :)

thx schonmal

[edit=Luckie]Delphi-Tags eingefügt. Mfg, Luckie[/edit]

Luckie 1. Feb 2004 19:19

Re: FindwindowEx
 
Steht in dem Edit "TEdit" drin? Btwe. Muss es heißen:
Delphi-Quellcode:
SendMessage(Handle,WM_SETTEXT,0,Integer(@Eingabe[1]));
Eine Fehlermeldung wäre auch nicht schlecht.

ReCoVeR 1. Feb 2004 19:32

Re: FindwindowEx
 
keine fehlermeldung! das isses ja =(

toms 1. Feb 2004 19:47

Re: FindwindowEx
 
Zitat:

ich will mit FindWindowEx einen string, in ein anderes fenster einfügen, doch in dem anderem fenster gibt es 4x TEdit....
Sollte so funktionieren:

Delphi-Quellcode:
function FindControlByNumber(hApp: HWND; ClassName: string; ControlNr: Word = 1): HWND;
var
  i: Word;
  hControl: HWND;
begin
  Result := 0;
  if IsWindow(hApp) then
  begin
    Dec(ControlNr);
    hControl := 0;
    for i := 0 to ControlNr do
    begin
      hControl := FindWindowEx(hApp, hControl, PChar(ClassName), nil);
      if hControl = 0 then
        Exit;
    end;
  end;
  Result := hControl;
end;

procedure SetEditText(hApp: HWND; ClassName, AText: string; EditNr: Integer);
var
  hEdit: HWND;
begin
  hEdit := FindControlByNumber(hApp, ClassName, EditNr);
  if hEdit <> 0 then
    SendMessage(hEdit, WM_SETTEXT, 0, Integer(PChar(AText)));
end;

// dem "4." Edit vom Fenster TForm1 Text senden.
procedure TForm1.Button1Click(Sender: TObject);
begin
  SetEditText(FindWindow('TForm1', nil),'TEdit','alalalala',4);
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:15 Uhr.

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