Autor Beitrag
Soulama
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72



BeitragVerfasst: Do 04.11.04 15:56 
Hi,
möchte den Namen eines Component wissen, von dem ich nur den Handle habe ?
hat jemand eine Idee ?
Soulama
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Fr 05.11.04 00:31 
Soulama hat folgendes geschrieben:
möchte den Namen eines Component wissen, von dem ich nur den Handle habe?

Von welchem Handle? Vom Fensterhandle, Instanzenhandle oder?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
function GetComponentNameFromWndHandle(Handle: HWND): String;

  function GetComponentName(AComponent: TComponent; AHandle: HWND): String;
  var
    I: Integer;
  begin
    for I := 0 to AComponent.ComponentCount - 1 do
      if (AComponent.Components[I] as TWinControl).Handle = AHandle then
        Result := (AComponent.Components[I] as TWinControl).Name
      else
        Result := GetComponentName(AComponent.Components[I], AHandle);
  end;

begin

  Result := GetComponentName(Application, Handle);

end;

_________________
Ciao, Sprint.
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Fr 05.11.04 00:35 
Hatte die "is" Abfrage vergessen...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
function GetComponentNameFromWndHandle(Handle: HWND): String;

  function GetComponentName(AComponent: TComponent; AHandle: HWND): String;
  var
    I: Integer;
  begin
    for I := 0 to AComponent.ComponentCount - 1 do
      if AComponent.Components[I] is TWinControl then
        if (AComponent.Components[I] as TWinControl).Handle = AHandle then
          Result := (AComponent.Components[I] as TWinControl).Name
        else
          Result := GetComponentName(AComponent.Components[I], AHandle);
  end;

begin

  Result := GetComponentName(Application, Handle);

end;

_________________
Ciao, Sprint.
Soulama Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 72



BeitragVerfasst: Fr 05.11.04 12:00 
Danke für deine hilfe.
Soulama.