Autor Beitrag
Crowbar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 180

WinXP, SP2
D6 Enterprise
BeitragVerfasst: Fr 06.05.05 13:47 
Hi,
ist es möglich, die Anzahl und vor allem die Namen meiner verwendeten Komponenten zur Laufzeit zu ermittel bzw. aufzulisten?
Z.B. habe ich eine Form1 und darauf befinden sich 3 TButtons (Button1, Button2, Button3) und einige TLabels.
Natürlich weiss ich als Programmierer, wieviele Buttons (mit deren Bezeichnung) ich benutzt habe.
Aber kann man dies auch zur Laufzeit z.B. in eine Liste auflisten lassen.

Der Hintergrund ist, das ich die Komponentenpositon, -höhe, - breite usw. bei einer anderen Bildschirmauflösung entsprechend anpassen möchte:
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:
procedure TForm1.FormActivate(Sender: TObject);
const
     //Bildschirmauflösung (beim Programmieren)
     x:integer=800;
     y:integer=600;
var
   bildbreite,bildhoehe:integer;
begin
     //den Variablen die Bildschirmhoehe und -breite zuweisen
     bildbreite:=screen.width;
     bildhoehe:=screen.height;

     //Wenn eine andere Bildschirmauflösung verwendet wird
     if (bildbreite<>x) and (bildhoehe<>y) then
     begin

    //Die Größe aller Komponenten auf die neue Bildschirmauflösung umberechnen
          Komponente1.Width:=round(Komponente1.Width*(Bildbreite / x));
          Komponente1.Height:=round(Komponente1.Height*(Bildhoehe / y));

    //Die Größe des Formulars umberechnen
          Form1.Width:=round(Form1.Width*(Bildbreite / x));
          Form1.Height:=round((Form1.Height-24)*(Bildhoehe / y))+24;

    //Position der Komponenten umberechnen
          Komponente1.Left:=round(Komponente1.Left*(Bildbreite / x));
          Komponente1.Top:=round(Komponente1.Top*(Bildhoehe / y));
     end;

     //Formular in die Mitte des Bildschirms setzen
     Form1.Left:=Screen.Width div 2 - Form1.Width div 2;
     Form1.Top:=Screen.Height div 2 - Form1.Height div 2;
end;


Cu
Crowbar
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Fr 06.05.05 14:27 
Hallo!

Such mal in der Hilfe und im Forum nach Suche in: Delphi-Forum, Delphi-Library COMPONENTCOUNT und Suche in: Delphi-Forum, Delphi-Library COMPONENTS.

Gruß
Tino
Crowbar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 180

WinXP, SP2
D6 Enterprise
BeitragVerfasst: Fr 06.05.05 14:33 
Vielen Dank!
Ich habe es jetzt unter "Deinen Such-Tip" gefunden. :)

Cu
Crowbar
HECHT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24


D7
BeitragVerfasst: Fr 06.05.05 15:36 
Spy++ von Microsoft ist Bestandteil von VS-Studio.. das Progi kann dir recht viel über die Komponenten zur Laufzeit erzählen, ohne dass du dazu Code schreiben musst. Ist noch gut um das UI zu testen..

ich glaube sogar Motzi hat auch mal so ein Spy Progi geschrieben und hier gepostet...
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 08.05.05 20:45 
user profile iconHECHT hat folgendes geschrieben:
ich glaube sogar Motzi hat auch mal so ein Spy Progi geschrieben und hier gepostet...

Jap.. nennt sich X-Spy und ist in der Freeware-Sparte zu finden. Es gibt aber auch eine eigene Homepage unter www.x-spy.net

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!