| Autor |
Beitrag |
masteroffinalfantasy
      
Beiträge: 82
Win XP
Delphi 2005 Architect
|
Verfasst: Do 31.05.07 11:48
Moin
Ich bin gerade dabei mich ein bisschen mit Handles etc ausseinander zu setzten. Nur leider fällt mir partout nicht ein wie ich aus einer Listbox, wo der Handle Name gespeichert ist, den wieder in eine hwnd variable bekomme...
Also ich hab folgende Funktion:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
| function EnumWinProc(Wnd: THandle; LParam: LongInt): Boolean; stdcall; var WinCaption : string; Len: integer;
begin Result := True; Len := GetWindowTextLength(Wnd); SetLength(WinCaption, Len); GetWindowText(Wnd, PChar(WinCaption), Len+1); if Trim(WinCaption) <> '' then begin Form2.Listbox1.Items.Add(Format('%.6x : %s', [Wnd, WinCaption])); end; end; |
Die Items in Listbox1 werden dann so in die Listbox 2 übertragen...
Delphi-Quelltext 1:
| Listbox2.Items.Add(Format('%.6x : %s', [Listbox1.Items.Strings[Listbox1.ItemIndex]])) |
Dann soll folgende Procedur aufgerufen werden
Delphi-Quelltext 1: 2: 3: 4:
| procedure SetWindowPosToFront(process:HWND); begin SetWindowPos(process,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE); end; |
da wollte ich über einen Timer dynamisch die Items aus der Listbox auslesen und dann die Procedur aufrufen
So weit 
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 31.05.07 12:24
Moin!
Pack doch in die .Objects[] das Handle binär rein.
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
masteroffinalfantasy 
      
Beiträge: 82
Win XP
Delphi 2005 Architect
|
Verfasst: Do 31.05.07 12:28
Narses hat folgendes geschrieben: | Moin!
Pack doch in die .Objects[] das Handle binär rein.
cu
Narses |
There are 10 types of people - those who understand binary and those who don´t.
Ich gehör zur zweiten Gruppe T_T
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 31.05.07 12:37
Moin!
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
| function EnumWinProc(Wnd: THandle; LParam: LongInt): Boolean; stdcall; var WinCaption : string; Len: integer; begin Result := True; Len := GetWindowTextLength(Wnd); SetLength(WinCaption, Len); GetWindowText(Wnd, PChar(WinCaption), Len+1); if (Trim(WinCaption) <> '') then Form2.Listbox1.Items.AddObject(Format('%.6x : %s', [Wnd, WinCaption]),TObject(Wnd)); end; |
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
masteroffinalfantasy 
      
Beiträge: 82
Win XP
Delphi 2005 Architect
|
Verfasst: Do 31.05.07 12:44
Ach so meinst das.
Dann geht aber der Aufruf nicht...
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7:
| process:=Listbox2.Items.Objects[counter]; SetWindowPosToFront(process); [..] procedure SetWindowPosToFront(process:HWND); begin SetWindowPos(process,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE); end; |
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 31.05.07 12:55
Moin!
masteroffinalfantasy hat folgendes geschrieben: | Die Items in Listbox1 werden dann so in die Listbox 2 übertragen...
Delphi-Quelltext 1:
| Listbox2.Items.Add(Format('%.6x : %s', [Listbox1.Items.Strings[Listbox1.ItemIndex]])); | |
Du kopierst die Objects so auch nicht mit; probier mal:
Delphi-Quelltext 1:
| Listbox2.Items.Assign(Listbox1.Items); |
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
masteroffinalfantasy 
      
Beiträge: 82
Win XP
Delphi 2005 Architect
|
Verfasst: Do 31.05.07 13:04
hmm das problem ist, das die aufgerufenen Prozedur ein HWND will, aus der Listbox aber ein TObject rauskommt...
(btw danke das du dich dem problem überhaupt annimmst)
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 31.05.07 13:07
Moin!
Dann machst du halt einen Cast auf HWND...
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
masteroffinalfantasy 
      
Beiträge: 82
Win XP
Delphi 2005 Architect
|
Verfasst: Do 31.05.07 13:13
omg ich bin zu doof
also ich will die zwei prozeduren aufrufen lassen
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
| procedure SetWindowPosToFront(process:HWND); begin SetWindowPos(process,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE); end;
procedure SetWindowPosToBack(process:HWND); begin SetWindowPos(process,HWND_NOTOPMOST,0,0,0,0,SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE); end; procedure TForm2.Button1Click(Sender: TObject); begin EnumWindows(@EnumWinProc, 0); end; |
und zwar damit :
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10:
| procedure TForm2.Timer1Timer(Sender: TObject); var counter:integer; begin
if counter>0 then SetWindowPosToBack(process); counter:=counter+1; process:=Listbox2.Items.Objects[counter]; SetWindowPosToFront(process);
end; |
und wo soll ich was "casten"?^^
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 31.05.07 13:22
Moin!
Delphi-Quelltext 1:
| process := HWND(Listbox2.Items.Objects[counter]); |
Hast du doch beim Einfügen per .AddObject auch gemacht, nur eben "andersrum".
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
masteroffinalfantasy 
      
Beiträge: 82
Win XP
Delphi 2005 Architect
|
Verfasst: Do 31.05.07 13:34
Narses hat folgendes geschrieben: | Moin!
Delphi-Quelltext 1:
| process := HWND(Listbox2.Items.Objects[counter]); |
Hast du doch beim Einfügen per .AddObject auch gemacht, nur eben "andersrum".
cu
Narses |
^^ ja ich werd noch ganz kirre mit den ganzen HWND und OBJECTS und haste nicht gesehen XD
so mal testen^^
EDIT:
Scheint zu funktionieren n1^^
Wenn du mir jetzt noch erklärst wie ich die Einträge von Listbox1 zu Listbox2 einzeln rüberbekomme bist du mein Held^^ (naja bist ja eh jetzt schon  )
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 31.05.07 13:49
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
masteroffinalfantasy 
      
Beiträge: 82
Win XP
Delphi 2005 Architect
|
Verfasst: Do 31.05.07 13:55
Ich nehm mal an du meinst ich soll das analog machen^^
also dann
Delphi-Quelltext 1:
| Listbox2.Items.AddObject(Listbox1.Items.Objects[Listbox1.ItemIndex])); |
aber der will da strings ^^
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 31.05.07 14:20
Moin!
Aaaalso...
| DOH hat folgendes geschrieben: | Delphi-Quelltext 1:
| function AddObject(const S: string; AObject: TObject): Integer; | |
Das hier ist das aktuell markierte Object aus Listbox1:
Delphi-Quelltext 1:
| Listbox1.Items.Objects[Listbox1.ItemIndex]); |
Und das hier der Text dazu:
Delphi-Quelltext 1:
| Listbox1.Items.Strings[Listbox1.ItemIndex]); |
Was schätzt du denn, wie dann der .AddObject-Aufruf für Listbox2 aussehen muss, hm?
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
masteroffinalfantasy 
      
Beiträge: 82
Win XP
Delphi 2005 Architect
|
Verfasst: Do 31.05.07 14:28
^^
so?
Delphi-Quelltext 1:
| Form2.Listbox2.Items.AddObject(Listbox1.Items.Strings[Listbox1.ItemIndex],Listbox1.Items.Objects[Listbox1.ItemIndex]); |
|
|
Narses
      

Beiträge: 10185
Erhaltene Danke: 1261
W11x64
TP3 .. D7pro .. D10.2CE
|
Verfasst: Do 31.05.07 14:29
Moin!
Hast du´s denn nicht probiert?
cu
Narses
_________________ There are 10 types of people - those who understand binary and those who don´t.
|
|
masteroffinalfantasy 
      
Beiträge: 82
Win XP
Delphi 2005 Architect
|
Verfasst: Do 31.05.07 14:32
doch gerade eben
Danke dir vielmals!
|
|