Autor Beitrag
Markus254
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 23

Winnt2000
d7 Prof
BeitragVerfasst: Mo 02.07.07 20:33 
Hi Team

Habe da so ein Problem...
Durch eine Prozedur bekomme ich alle Programme in meine Listbox, die in der Taskbar sind.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
function EnumWindowsProc(Wnd: HWND; lParam: lParam): BOOL; stdcall;
begin
  Result := True;
  if (IsWindowVisible(Wnd) or IsIconic(wnd)) and
    ((GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) or
    (GetWindowLong(Wnd, GWL_HWNDPARENT) = GetDesktopWindow)) and
    (GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW = 0) then
    Form1.Listbox1.Items.Add('Handle: ' + IntToStr(Wnd) + ',Text:  ' + GetText(Wnd));
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  Param: Longint;
begin
  EnumWindows(@EnumWindowsProc, Param);
end;


Nun habe ich zwei solche listen. Die eine(Listbox1) wird sekundlich aktualisiert und die andere (Listbox2) übernimmt vorher Listbox1. Die will ich nun so vergleichen, dass ich den start des neuen Prozessen herausschreiben kann.
Hab folgendes schon versucht, doch es funktioniert nicht...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
  if listbox1.Count > listbox2.Count then
  begin
    for i := 0 to (listbox2.Count - listbox1.Count+1) do
    listbox2.Items.Add('zleer');

    for i := 0 to listbox2.Count-1 do
    begin
      for x := 0 to listbox1.Count-1 do
      begin
        if listbox1.Items.Strings[i] <> listbox2.Items.Strings[x]
        then f := f+1 else
        begin
          f := 0;
          break;
        end;
        if f = listbox1.Count-1 then L := x;
      end;
    end;


Am ende sollte ich einfach wissen, das der neue String, also Text des gestarteten Prozess, and der [L] stelle von der Listbox1 ist, doch [L] hat immer einen anderen Wert... :oops:

Danke im voraus !
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 02.07.07 21:28 
Moin!

Probier das mal so: ;)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  var
    i: Integer;
begin
  for i := 0 to ListBox1.Count-1 do
    if (ListBox2.Items.IndexOf(ListBox1.Items.Strings[i]) = -1) then
      ShowMessage('Neu: '+ListBox1.Items.Strings[i]);

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.