Eigene Komponente von TGraphicControl abgeleitet
spacer
Autor Nachricht
dontello
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58
Erhaltene Danke: 2



BeitragVerfasst: Fr 13.05.11 16:48 
Hallo,

ich teste mich gerade mal an die Komponentenprogrammierung ran und habe mir eine Klasse von TGraphicControl abgeleitet.
Dort habe ich die Paint Funktion überschrieben. Wenn ich nun die Komponente in ein Formular einbaue, wird mir alles soweit angezeigt, nur beim starten des Programms habe ich ein leeres Formular. Muss ich die Paintfunktion noch irgendwie aufrufen bevor sie ausgeführt wird?
Ist doch sicher nur eine Kleinigkeit irgendwo, die ich nicht bedacht habe.


Moderiert von user profile iconNarses: Topic aus VisualCLX (Component Library for Cross Platform) verschoben am Do 12.04.2012 um 22:53
 
Antworten mit Zitat Beitrag melden
Private Nachricht sendenPosting in privater Nachricht zitieren
Werbung ausblenden? Dann registriere Dich kostenlos. Weitere Gründe für eine Registrierung.


Werbung ausblenden? Dann registriere Dich kostenlos. Weitere Gründe für eine Registrierung.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 15840
Erhaltene Danke: 741

XP, W7 x64 (Chrome, IE9, FF), Debian, (OSX 10.7)
RAD XE 2, Java (NB), C++, C# (VS 2010), JS/HTML, PHP, Lazarus
BeitragVerfasst: Fr 13.05.11 16:54 
Die wird automatisch aufgerufen, der Fehler muss woanders liegen. Aber wo lässt sich ohne mehr Details / Code nicht sagen. :gruebel:
 
Antworten mit Zitat Beitrag melden
Private Nachricht sendenPosting in privater Nachricht zitieren
dontello Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58
Erhaltene Danke: 2



BeitragVerfasst: Fr 13.05.11 16:58 
Ok, dann hier mal der Code. Vielleicht lässt sich ja was erkennen.
ausblenden volle Höhe Delphi-Quelltext markieren
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:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
unit noten;

interface

uses
SysUtils, Classes, Controls, Graphics;

type
TNotes = class(TGraphicControl)
private
{ Private-Deklarationen }
FLines : Integer;
procedure SetLines(Value: Integer);
protected
{ Protected-Deklarationen }
procedure Paint; override;
public
{ Public-Deklarationen }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published-Deklarationen }
property Lines: Integer read FLines write SetLines;
end;

procedure Register;


implementation

//------------------------------------------------------------------------------

constructor TNotes.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

FLines := 0;
end;
//------------------------------------------------------------------------------

destructor TNotes.Destroy;
begin
inherited Destroy;
end;
//------------------------------------------------------------------------------

procedure TNotes.SetLines(Value: Integer);
begin
if FLines <> Value then
begin
FLines := Value;
Invalidate;
end;
end;

//------------------------------------------------------------------------------

procedure TNotes.Paint;
var
LineCount: Integer;
count: Integer;
hl: Integer;
ho, hu: Integer;
begin

LineCount := Lines;
//Wenn sich die Komponente in Entwicklung befindet
if csDesigning in ComponentState then
begin
// Notenlinien Zeichen Violin- / Bassschlüssel

hl := 10;
ho := 10;
hu := 130;

for count := 1 to Linecount do
begin
Canvas.Pen.Width := 3;
Canvas.MoveTo(Width - (Width - 10), Height - (Height - ho));
Canvas.LineTo(Width - (Width - 10), Height - (Height - hu));

Canvas.Pen.Width := 1;

Canvas.MoveTo(width - (width-15), Height - (Height - ho));
Canvas.LineTo(width - (width-15), Height - (Height - hu));
// Linie 1 Violin
Canvas.MoveTo(width - (width-10), Height - (Height - hl));
Canvas.LineTo(width - 10, Height - (Height - hl));
// Linie 2 Violin
Canvas.MoveTo(width - (width-10), Height - (Height - hl - 10));
Canvas.LineTo(width - 10, Height - (Height - hl - 10));
// Linie 3 Violin
Canvas.MoveTo(width - (width-10), Height - (Height - hl-20));
Canvas.LineTo(width - 10, Height - (Height - hl-20));
// Linie 4 Violin
Canvas.MoveTo(width - (width-10), Height - (Height - hl-30));
Canvas.LineTo(width - 10, Height - (Height - hl-30));
// Linie 5 Violin
Canvas.MoveTo(width - (width-10), Height - (Height - hl-40));
Canvas.LineTo(width - 10, Height - (Height - hl-40));
// Linie 1 Bass
Canvas.MoveTo(width - (width-10), Height - (Height - hl-80));
Canvas.LineTo(width - 10, Height - (Height - hl-80));
// Linie 2 Bass
Canvas.MoveTo(width - (width-10), Height - (Height - hl-90));
Canvas.LineTo(width - 10, Height - (Height - hl-90));;
// Linie 3 Bass
Canvas.MoveTo(width - (width-10), Height - (Height - hl-100));
Canvas.LineTo(width - 10, Height - (Height - hl-100));
// Linie 4 Bass
Canvas.MoveTo(width - (width-10), Height - (Height - hl-110));
Canvas.LineTo(width - 10, Height - (Height - hl-110));
// Linie 5 Bass
Canvas.MoveTo(width - (width-10), Height - (Height - hl-120));
Canvas.LineTo(width - 10, Height - (Height - hl-120));

Canvas.MoveTo(width - 15, Height - (Height - ho));
Canvas.LineTo(width - 15, Height - (Height - hu));

Canvas.Pen.Width := 3;
Canvas.MoveTo(width - 10, Height - (Height - ho));
Canvas.LineTo(width - 10, Height - (Height - hu));

hl := hl + 150;
ho := ho + 150;
hu := hu + 150;
end;

end;
end;
//------------------------------------------------------------------------------

procedure Register;
begin
RegisterComponents('Musik', [TNotes]);
end;

end.
 
Antworten mit Zitat Beitrag melden
Private Nachricht sendenPosting in privater Nachricht zitieren
dontello Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58
Erhaltene Danke: 2



BeitragVerfasst: Fr 13.05.11 17:02 
Fehler gefunden.

Paint wurde nur ausgeführt im Entwicklungsmodus. Sorry ^^
 
Antworten mit Zitat Beitrag melden
Private Nachricht sendenPosting in privater Nachricht zitieren
home home