Autor Beitrag
Schakal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 50



BeitragVerfasst: Mi 03.12.03 21:33 
Ich code gerade ein kleines Tool und bin da stecken geblieben :D
also ich habe in meinem programm die funktion eingebaut, dass wenn ich mit dem mauszeiger über eine form irgendeines programmes gehe man den classname sieht.
jetzt will ich aber, dass sobald er den classname anzeigt, falls die form auf die gezeigt wird den classname TScriptListBox hat, diese ListBox "extrahiert" in m eine memo1. wie geht das?
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Mi 03.12.03 21:38 
Hi!

Du brauchst die SendMessage API.
Dann diese Parameter:

LB_GETCOUNT zum Zählen der Items in der Listbox

LB_GETTEXTLEN zum Ermitteln der Länge eines Items.

LB_GETTEXT zum holen eines Itemtexts.


Habe hier mal ein Beispiel geschrieben:

www.swissdelphicente...showcode.php?id=1335
Schakal Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 50



BeitragVerfasst: Mi 03.12.03 22:11 
ausblenden Quelltext
1:
hListBox := {...}; // listbox handle					

was bedeutet das? was kommt da rechts anstatt der klammer hin? der klassenname der scriptbox?[/delphi][/quote]
Schakal Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 50



BeitragVerfasst: Mi 03.12.03 23:25 
also ich hab mal bisher folgendes, funzt einfach ned, ka wieso, raff das ned :D
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:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type 
  TForm1 = class(TForm) 
    Label1: TLabel; 
    Label2: TLabel; 
    Timer1: TTimer;
    Image1: TImage;
    Edit1: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    Memo1: TMemo;
    ListBox1: TListBox;
    procedure Zahlen(Sender: TObject; var Key: Char);
    procedure TimerAus(Sender: TObject);
    procedure Extrahieren(CrPos: TPoint);
    procedure TimerAn(Sender: TObject);
  private

  public 

end; 

var 
  Form1: TForm1; 

implementation 

{$R *.DFM}
////////////////////////////////////////////////////////////////////////////////

{Anzahl Zeilen-Einträge einer ListBox ermitteln}
function Zeilen(hListBox: THandle): Integer;
begin
  Result := SendMessage(hListBox, LB_GETCOUNT, 0, 0);
end;

////////////////////////////////////////////////////////////////////////////////

{Gibt den gesamten Text einer ListBox zurück}
function AlleZeilen(hWnd: Hwnd; sl: TStrings): string;
var
  RetBuffer: string;
  i, x, y: Integer;
begin
  x := SendMessage(hWnd, LB_GETCOUNT, 0, 0);
  for i := 0 to x - 1 do
  begin
    y := SendMessage(hWnd, LB_GETTEXTLEN, i, 0);
    SetLength(RetBuffer, y);
    SendMessage(hWnd, LB_GETTEXT, i, lParam(PChar(RetBuffer)));
    sl.Add(RetBuffer);
  end;
end;

////////////////////////////////////////////////////////////////////////////////

{Editfeld nur Zahlen zulassen}
procedure TForm1.Zahlen(Sender: TObject; var Key: Char);
begin
    if not (key in [#8, #9, #48 .. #57]) then key:=#0;
end;

////////////////////////////////////////////////////////////////////////////////

procedure TForm1.TimerAus(Sender: TObject);
var 
  rPos: TPoint; 
begin 
  if Boolean(GetCursorPos(rPos)) then Extrahieren(rPos);
  Timer1.Enabled := False;
end;

////////////////////////////////////////////////////////////////////////////////

procedure TForm1.Extrahieren(CrPos: TPoint);
var 
  hWnd: THandle; 
  aName: array [0..255] of Char;
  //
  sl: TStringList;
  ListBox_Handle: THandle;
begin
  hWnd := WindowFromPoint(CrPos); 
  Label1.Caption := 'Handle :  ' + IntToStr(hWnd);

  if Boolean(GetClassName(hWnd, aName, 256)) then
      Label2.Caption := 'ClassName :  ' + string(aName);
      ListBox_Handle := StrToInt(aName);
      sl := TStringList.Create;
      ListBox1.Items.Text := sl.Text;
      sl.Free
end;

////////////////////////////////////////////////////////////////////////////////

procedure TForm1.TimerAn(Sender: TObject);
begin
  Timer1.Enabled := True;
  Timer1.Interval := 3000;
end;

////////////////////////////////////////////////////////////////////////////////
end.

durch klick auf das Image wird der Timer aktiviert, nach 3 sekunden ist der timer auf 0 dann wird die procedur TForm1.Extrahieren ausgeführt, die ja dann das zeugs machen soll. geht aber ned. bitte um hilfe :D

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.