Autor Beitrag
meolus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 78

Gentoo, Debian, Win7 64-bit, WinXP
Delphi 2006 Prof., Delphi 2005 PE
BeitragVerfasst: Sa 30.07.05 17:24 
Ich würde gerne eine Klasse basteln, wo ein TProgressBar auf einem TPanel liegt. Mein Bisheriger Anfang sieht so aus:
ausblenden 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:
unit MsgPanel;

interface

uses ExtCtrls, Classes, Controls, QComCtrls;

type
  TMsgPanel = class(TPanel)
  private
    ProgressBar: TProgressBar;
  public
    constructor Create(AOwner: TComponent);
  end;

implementation

constructor TMsgPanel.Create(AOwner: TComponent);
begin
  inherited;
  Parent := TWinControl(AOwner); //"Automatisches" Anzeigen auf dem Erstellerobjekt

  ProgressBar := TProgressBar.Create(self);
end; (*Create*)


Nachdem ich den TProgressBar erzeugt habe weiß ich nicht mehr weiter, oder war das createn mit dem "self" sogar schon falsch?
Wie bekomme ich nun, den ProgressBar auf dem TPanel angezeigt?

Den Parent bekomme ich einfach nicht gesetzt, da der als Partent einen TWidgetControl angegeben haben möchte, ich damit aber nichts so recht anfangen kann! Wenn ich das so einfach "ProgressBar.Parten := TWidgetControl(self);" anfüge, dann habe ich nachdem ich das uses für QControl eingefügt habe, weil der das sonst nicht konnte, ein riesen Problem mit dem TWinControl :(

_________________
Real programmers don't comment their code;
if it was hard to write, it should be hard to read.
Michael Stenzel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 133


D3 Prof, D7 PE
BeitragVerfasst: So 31.07.05 03:24 
Hi meolus!

Du muß das Parent von der ProgressBar auf Self setzen, dann läuft es.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
constructor TMsgPanel.Create(AOwner: TComponent);
begin
  inherited;
  Parent := TWinControl(AOwner); //"Automatisches" Anzeigen auf dem Erstellerobjekt

  ProgressBar := TProgressBar.Create(self);
  ProgressBar.Parent := self; // <-- 
  ProgressBar.Position := 59;
  ProgressBar.Top := 10;
  ProgressBar.Left := 10;
end; (*Create*)


gruß
Michael.
meolus Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 78

Gentoo, Debian, Win7 64-bit, WinXP
Delphi 2006 Prof., Delphi 2005 PE
BeitragVerfasst: So 31.07.05 07:59 
Vielen Dank für die Antwort, aber leider bekomme ich dann für
ausblenden Delphi-Quelltext
1:
ProgressBar.Parent := self;					

diese Fehlermeldung:

"Inkompatible Typen: 'TWidgetControl' und 'TMsgPanel'". :-/

_________________
Real programmers don't comment their code;
if it was hard to write, it should be hard to read.
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: So 31.07.05 08:02 
Ist zwar hässlich, aber müsste gehen :twisted:

ausblenden Delphi-Quelltext
1:
FProgressBar.Parent := self as TWinControl;					


Außerdem: Variablen im private-Bereich immer mit F beginnen lassen, damit man weiß, dass es eben solche sind.

AXMD
meolus Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 78

Gentoo, Debian, Win7 64-bit, WinXP
Delphi 2006 Prof., Delphi 2005 PE
BeitragVerfasst: So 31.07.05 08:08 
Leider geht
ausblenden Delphi-Quelltext
1:
FProgressBar.Parent := self as TWinControl;					

auch nicht. Dafür habe ich jetzt aber das Problem doch noch gefunden, warum das nicht geht!

Wenn ich als uses "ComCtrls" anstelle von den "QComCtrls" benutze, dann gehen beide von euch vorgeschlagenen Lösungen! :?


Das mit dem "F" möchte ich gerne übernehmen, aber wofür steht das?
Wo ist der Unterschied zwischen den "Standard"-uses mit und ohne das "Q" davor? Die einen sind die VCL und die anderen die CLX, oder? Aber warum geht dass dann mit den einen und mit den anderen nix?

_________________
Real programmers don't comment their code;
if it was hard to write, it should be hard to read.
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: So 31.07.05 08:11 
user profile iconmeolus hat folgendes geschrieben:
Das mit dem "F" möchte ich gerne übernehmen, aber wofür steht das?

Wofür es genau steht weiß ich nicht, aber auch bei Variablen für Properties gibts du ein F davor an - das hat sich einfach "eingebürgert".
user profile iconmeolus hat folgendes geschrieben:
Wo ist der Unterschied zwischen den "Standard"-uses mit und ohne das "Q" davor? Die einen sind die VCL und die anderen die CLX, oder? Aber warum geht dass dann mit den einen und mit den anderen nix?

Andere Klassen nehme ich an. Ich kenn die CLX nicht, aber ich denke, dass sie aus etwas anderen Klassen aufgebaut sein wird als die VCL.

AXMD