Autor Beitrag
Insignificant
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 01.04.06 18:09 
Ich bin dabei die Laufenden sichtbaren Anwendungen auszulesen und diese in mein Programm zu integrieren. Naja zur Zeit mache ich es so das ich mit einer Funktion die Fenster auslese.

Anschließend liste ich mit einer procedure
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm2.BuildArray();
var
 I: Integer;
begin
 EnumWindows(@EnumWindowsProc, 0);
 with Form2.ListBox1.Items do
  begin
   Clear;
   for I:=0 to Length(FensterInfo) - 1 do
    begin
     Add(FensterInfo[I].Caption);
    end;
  end;
end;


die Fenster in eine Listbox auf und erstelle aus der Listbox dann die Tasks

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
for i := 1 to listbox1.items.count-1 do
begin
task[1]:= TImageEx.Create(nil);
with task[1] do
        begin
...etc

Ich finde den Schritt mit der Listbox jedoch total überflüssig. Darum wollte ich nun anstatt die FensterInfo erst in eine Listbox zusetzten, direkt die Tasks von der FensterInfo (array) erstellen. Kann mir da jemand helfen?
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 01.04.06 18:22 
Wo ist denn deine EnumWindowsProc?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
var
  sl: TStringList;

function EnumWindowsProc(hWnd: THandle; lp: LPARAM): Boolean;
begin
  sl.Add(IntToStr(hWnd));
  Result := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
begin
  sl := TStringList.Create;
  EnumWindows(@EnumWindowsProc, 0);
  // was auch immer du mit den Handles machen willst, tu es ab hier
  for i := 0 to sl.Count - 1 do
    ListBox1.Items.Add(sl.Strings[i]);
end;
Insignificant Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 01.04.06 18:59 
Meine EnumWindowsProc gibts auch *g*

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Function EnumWindowsProc(Wnd: HWND): BOOL; StdCall;     
Var
  Capt: Array [0..128] of Char;
Begin
  Result:=true;
  If IsWindowVisible(Wnd) and
     ((GetWindowLong(Wnd, GWL_HWNDPARENT)=0) or
      (HWND(GetWindowLong(Wnd, GWL_HWNDPARENT))=GetDesktopWindow)) and
     ((GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW)=0)
  then
  begin
    SendMessage(Wnd, WM_GETTEXT, Sizeof(Capt), integer(@Capt));
    SetLength(FensterInfo, length(FensterInfo)+1);    
    inc(lengthvar);
    FensterInfo[High(FensterInfo)].Caption:=Capt;
    FensterInfo[High(FensterInfo)].Handle:=Wnd;
  end;
end;


Mit deinem Quelltext kann ich jedoch nicht so viel mit anfangen da er sich ja auch wieder auf eine Listbox bezieht, welche ich ja nicht mehr in meinem Projekt integriert haben möchte.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 01.04.06 19:06 
Und wo kommt da jetzt zwingenderweise die Listbox ins spiel?
Insignificant Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 01.04.06 19:08 
Die listbox kommt in der procedure oben ins Spiel damit ich dann die einzelnen Tasks erstellen kann......pro list-item -> ein task...aber ich denke das man die listbox ja halt weglassen kann.....das man es mit den arrays von oben aus der funktion machen kann....
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
for i := 1 to listbox1.items.count-1 do  
begin  
task[1]:= TImageEx.Create(nil);  
with task[1] do  
        begin


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 01.04.06 19:13 
Dann geh doch einfach dein Array durch und erstelle den Task, anstatt den Array-eintrag in die Listbox zu schreiben. Ich verstehe immer noch nicht, warum du meinst eine Listbox zu brauchen.
Insignificant Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: Sa 01.04.06 20:57 
Ja genau das hatte ich ja auch vor nur ich habe halt keine Idee wie ich das machen könnte. Darum erhoffe ich mir ja hier hilfe *g*.....neee ich bin ja der meinung das ich KEINE Listbox brauche......
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 01.04.06 21:09 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i := 0 to length(MyArray) - 1 do
begin
  tuwas[i] := MyArray[i].WasWeissIch;
end;
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 01.04.06 22:27 
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:
33:
procedure TForm2.BuildArray;
type
  TImageExArray = array of TImageEx;
  PImageExArray = ^TImageExArray;
var
  I: Integer;
  arr: TImageExArray;

  function EnumWindowsProc(hWnd: THandle; lp: LPARAM): Boolean; stdcall;
  Var
    Capt: Array [0..128] of Char;
    arr: PImageExArray;
  Begin
    arr := PImageExArray(lp);

    Result:=true;
    If IsWindowVisible(Wnd) and
       ((GetWindowLong(Wnd, GWL_HWNDPARENT)=0) or
        (HWND(GetWindowLong(Wnd, GWL_HWNDPARENT))=GetDesktopWindow)) and
       ((GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW)=0)
    then
    begin
      SendMessage(Wnd, WM_GETTEXT, Sizeof(Capt), integer(@Capt));
      SetLength(arr^, length(arr^)+1);    
      arr^[High(arr^)].Caption:=Capt;
      arr^[High(arr^)].Handle:=Wnd;
    end;
  end;

begin
  SetLength(Arr, 0);
  EnumWindows(@EnumWindowsProc, DWORD(@arr));
end;


Keine Garantie auf Korrektheit ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Insignificant Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 81



BeitragVerfasst: So 02.04.06 01:49 
Danke an euch beiden....habs selbst doch noch hinbekommen....*grr* voll der dumme fehler ^^ aba nu gehts...danke ^^