Autor Beitrag
HenryHux
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 542
Erhaltene Danke: 33

Windows 7 Premium
Delphi XE, Eclipse
BeitragVerfasst: Do 02.12.10 17:37 
Hi,

ich versuche die Handles von Fenstern mit gleichen Teilnamen herauszufinden.

Mein Ansatz sieht dazu bis jetzt so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure autosize;
var
  h : array [0..4of hWnd;
  i, nr : integer;
  g : array [0..4of hWnd;
begin
  nr:=0;
  for i:=0 to 4 do   
  begin
    h[i] := FindWindowByTitle('(editor)');
    if (h[i] <> 0and ((i<>0and (h[i]<>h[i-1]) or (i=0)) then
    begin
      g[nr]:=h[i];
      inc(nr);
    end
    else break; //provisorisch, wird geändert wenns klappt
  end;
  showmessage(inttostr(nr));
end;


Ich will also verschiedene Fenster finden, und nicht wie es so passiert 5 mal das gleiche.

Die Funktion FindWindowsByTitle stammt von hier:
www.swissdelphicente.../showcode.php?id=327 .

Was würdet ihr vorschlagen?

Lg

Henry
HenryHux Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 542
Erhaltene Danke: 33

Windows 7 Premium
Delphi XE, Eclipse
BeitragVerfasst: Do 02.12.10 19:08 
So, musste ich komplett umformen, ging mit dem Ansatz nicht. (zumindest bei mir :D)
Habe es so gemacht, klappt auch super.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
procedure findsimilarwindows;
var elements, i, position, nr : integer;
    line, dummy: string;
    title: array [0..10of string;
    windows : array [0..10of hWnd;
begin
  nr:=0;
  EnumWindows(@EnumWindowsProc, Integer(main.Listbox1));
  elements := main.listbox1.Count;
  for i:=0 to elements-1 do
  begin
    line:=main.listbox1.items[i];
    if pos('(partname)', line)>0 then
    begin
      dummy:=line;
      Delete(dummy,length(dummy) - 7,8);
      title[nr]:=dummy;
      inc(nr);
    end;
  end;
  if nr>0 then
  begin
    main.history.Lines.Add(inttostr(nr)+' Found');
    for i:=0 to nr do
    begin
      windows[i]:=FindWindowByTitle(title[i]);
      //ShowWindow(windows[i], SW_MAXIMIZE);
    end;
  end
  else
    main.history.Lines.Add('Didnt find anything');
end;


Lg

Henry