Autor Beitrag
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Di 28.01.03 22:57 
Hallo,

wie kann ich das Handle des Fensters rausfinden, auf dem ein TComponent platziert ist (also zur Laufzeit)?
LarsMiddendorf
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Di 28.01.03 23:28 
comp ist vom Type TComponent

TWinControl(comp.owner).handle

Normalerweise ist der Owner der Componente die Form.
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Di 28.01.03 23:49 
Danke!
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mi 29.01.03 08:16 
LarsMiddendorf hat folgendes geschrieben:
Normalerweise ist der Owner der Componente die Form.

Das sollte man aber vorher prüfen:
ausblenden Quelltext
1:
2:
3:
4:
if (Owner <> nil) and (Owner is TWinControl) then
  FormHandle := TWinControl(Owner).Handle
else
  FormHandle := 0;

_________________
Ist Zeit wirklich Geld?
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Mi 29.01.03 17:23 
Hallo @AndyB,

dein Cod eleuchtet ein, aber sag' mal, ein TComponent benötigt doch imme rein Fenster, oder? Ich meine, kann es sein, dass die Komponente zwar ein Fenster hat, das aber nicht = Owner ist? Oder gibt es auch TComponent ohne Fenster?
LarsMiddendorf
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Mi 29.01.03 20:49 
Der owner einer Komponente ist vom Type TComponent. Das kann z.B auch ein Datenmodul sein. Das Datenmodul stammt nicht von TWinControl ab und hat deshalb auch kein Fenster-Handle.
Andreas Pfau Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Mi 29.01.03 21:56 
Aha, OK, Danke! :D