Utilisateur anonyme
-
25 août 2008 à 17:16
cs_shining
Messages postés304Date d'inscriptionlundi 30 décembre 2002StatutMembreDernière intervention10 mars 2012
-
28 août 2008 à 17:36
Salut à tous,
J'ai un ptit soucis : j'ai fais un composant qui créer d'autres composants ent tant qu' enfants. Dans l'inspecteur d'objet, les propriétés des enfants apparaissent mais pas leur évènements et je ne comprend pas pourquoi :
destructor TBrowserTitle.Destroy;
begin
inherited;
end;
Procedure TBrowserTitle.setColorTitle(Value:TColor);
Begin
fColorTitle:=Value;
Invalidate;
End;
Procedure TBrowserTitle.setColorSubTitle(Value:TColor);
Begin
fColorSubTitle:=Value;
Invalidate;
End;
Procedure TBrowserTitle.setColorRectTitle(Value:TColor);
Begin
fColorRectTitle:=Value;
Invalidate;
End;
Procedure TBrowserTitle.SetTitle(Value:String);
Begin
fTitle:=Value;
Invalidate;
End;
Procedure TBrowserTitle.SetSubTitle(Value:String);
Begin
fSubTitle:=Value;
Invalidate;
End;
procedure TBrowserTitle.Resize;
Begin
Width:=113;
If Height<49 Then
Height:=49;
Invalidate;
End;
procedure TBrowserTitle.Paint;
Var
RectTitle:TRect;
WidthString,HeightString,LeftString,TopString:Integer;
Begin
InHerited;
With Canvas Do
Begin
Brush.Style:=BsClear;
With RectTitle Do
Begin
Left:=0;
Right:=Self.Width;
Top:=0;
Bottom:=49;
Brush.Color:=Self.fColorRectTitle;
Pen.Color:=ClBlack;
Pen.Width:=4;
Rectangle(RectTitle);
Font.Name:='Comic Sans MS';
Font.Size:=11;
Font.Color:=Self.fColorSubTitle;
WidthString:=TextWidth(fSubTitle);
HeightString:=TextHeight(fSubTitle);
LeftString:=Self.Width-WidthString-5;
TopString:=Bottom-Pen.Width-HeightString;
TextOut(LeftString,TopString,fSubTitle);
End;
End
End;
{>>TBrowserButton}
constructor TBrowserButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fClicked:=False;
end;
destructor TBrowserButton.Destroy;
begin
inherited;
end;
Procedure TBrowserButton.SetColorLine(Value:TColor);
begin
Self.fColorLine:=Value;
Self.Invalidate;
end;
Procedure TBrowserButton.SetColorTop(Value:TColor);
begin
Self.fColorTop:=Value;
Self.Invalidate;
end;
Procedure TBrowserButton.SetColorBottom(Value:TColor);
begin
Self.fColorBottom:=Value;
Self.Invalidate;
end;
Procedure TBrowserButton.SetCaption(Value:String);
begin
Self.fCaption:=Value;
Self.Invalidate;
end;
procedure TBrowserButton.Paint;
Var
RectTop,RectBottom : TRect;
HeightCaption, WidthCaption:Integer;
Begin
InHerited;
DrawBorder;
With Self.Canvas Do
Begin
Font:=Self.Font;
With RectTop Do
Begin
Top:=6;
Bottom:=Self.Height Div 2 ;
Left:=6;
Right:=Self.Width-6;
Brush.Color:=Self.fColorTop;
Pen.Color:=Self.fColorTop;
Rectangle(RectTop);
End;
With RectBottom Do
Begin
Top:=Self.Height Div 2;
Bottom:=Self.Height-6;
Left:=6;
Right:=Self.Width-6;
Brush.Color:=Self.fColorBottom;
Pen.Color:=Self.fColorBottom;
Rectangle(RectBottom );
End;
Brush.Color:=Self.fColorLine;
Pen.Color:=Self.fColorLine;
Pen.Width:=2;
MoveTo(5,Self.Height Div 2);
LineTo(Self.Width-7,Self.Height Div 2);
HeightCaption:=Self.Canvas.TextHeight(Self.Caption);
WidthCaption:=Self.Canvas.TextWidth(Self.Caption);
Brush.Style:=BsClear;
TextOut((Self.Width - WidthCaption) Div 2,(Self.Height - HeightCaption) Div 2, Self.Caption);
End;
End;
Procedure TBrowserButton.DrawBorder;
Var
LeftColor, RightColor:TColor;
UpperCorner,LowerCorner:Array [0..2] Of TPoint;
Begin
If Not fClicked Then
Begin
LeftColor:=ClWhite;
RightColor:=$00657271;
End
Else
Begin
LeftColor:=$00657271;
RightColor:=ClWhite;
End;
With Self.Canvas Do
Begin
Pen.Width:=2;
UpperCorner[0]:=Point(Pen.Width,Self.Height-Pen.Width);
UpperCorner[1]:=Point(Pen.Width,Pen.Width);
UpperCorner[2]:=Point(Self.Width-Pen.Width,Pen.Width);
LowerCorner[0]:=Point(Pen.Width,Self.Height-Pen.Width);
LowerCorner[1]:=Point(Self.Width-Pen.Width,Self.Height-Pen.Width);
LowerCorner[2]:=Point(Self.Width-Pen.Width,Pen.Width);
Brush.Color:=LeftColor;
Pen.Color:=LeftColor;
Polyline(UpperCorner);
Brush.Color:=RightColor;
Pen.Color:=RightColor;
Polyline(LowerCorner);
End;
End;
procedure TBrowserButton.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: integer);
Begin
InHerited;
If Shift=[SSLeft] Then
Begin
Self.fClicked:= True;
Self.Invalidate;
End;
End;
destructor TGaugeBar.Destroy;
begin
inherited;
end;
Procedure TGaugeBar.SetMin(Value:Integer);
Begin
If (Value<=fMax) And (Value<=fPos) Then
Begin
fMin:=Value;
Self.Invalidate;
End;
End;
Procedure TGaugeBar.SetMax(Value:Integer);
Begin
If (Value>=fMin) And (Value>=fPos) Then
Begin
fMax:=Value;
Self.Invalidate;
End;
End;
Procedure TGaugeBar.SetPos(Value:Integer);
Begin
If (Value>=fMin) And (Value<=fMax) Then
Begin
fPos:=Value;
Self.Invalidate;
End;
End;
Procedure TGaugeBar.SetStickColor(Value:TColor);
Begin
fStickColor:=Value;
Self.Invalidate;
End;
Procedure TGaugeBar.SetBackGroundColor(Value:TColor);
Begin
fBackGroundColor:=Value;
Self.Invalidate;
End;
Procedure TGaugeBar.SetFullColor(Value:TColor);
Begin
fFullColor:=Value;
Self.Invalidate;
End;
Procedure TGaugeBar.SetText(Value:String);
Begin
fText:=Value;
Self.Invalidate;
End;
Procedure TGaugeBar.Resize;
begin
inherited;
Height:=25;
end;
Procedure TGaugeBar.Paint;
Var
LeftRect,StickRect,BackGroundRect:TRect;
WidthText:Integer;
Str:String;
begin
inherited;
With Canvas Do
Begin
Font.Size:=8;
Pen.Width:=2;
Str:=fText+IntToStr(fPos);
WidthText:=(Width-TextWidth(Str)) Div 2;
Brush.Style:=BsClear;
TextOut(WidthText,0,Str);
With BackGroundRect Do
Begin
Left:=0;
Right:=Width;
Top:=15;
Bottom:=23;
Brush.Color:=fBackGroundColor;
Rectangle(BackGroundRect);
End;
With LeftRect Do
Begin
Left:=0;
Right:=Round(Width*(fPos-fMin) / (fMax-fMin));
Top:=15;
Bottom:=23;
Brush.Color:=fFullColor;
Rectangle(LeftRect);
End;
Brush.Color:=ClWhite;
Pen.Color:=ClWhite;
Pen.Width:=0;
MoveTo(4,19);
LineTo(Width-4,19);
With StickRect Do
Begin
Left:=Round(Width*((fPos-fMin) / (fMax-fMin))-0.01*Width);
Right:=Round(Width*((fPos-fMin) / (fMax-fMin))+0.01*Width);
If Left<=0 Then
Begin
Left:=0;
Right:=Round(0.02*Width);
End;
If Right>=Width Then
Begin
Left:=Round(Width*0.98);
Right:=Width;
End;
Top:=13;
Bottom:=25;
Brush.Color:=fStickColor;
Pen.Color:=ClBlack;
Pen.Width:=2;
Rectangle(StickRect);
End;
End;
End;
Procedure TGaugeBar.MouseDown(Button: TMouseButton; Shift: TShiftState;X, Y: integer);
Var
BnMax,BnMin : Integer;
begin
inherited;
If (Shift=[SSLeft]) Then
Begin
BnMin:=Round(Width*((fPos-fMin) / (fMax-fMin))-0.01*Width);
BnMax:=Round(Width*((fPos-fMin) / (fMax-fMin))+0.01*Width);
If (Shift=[SSLeft]) And (X>=BnMin) And (X<=BnMax) Then
fPos:=X*(fMax-fMin) Div Width+fMin;
If fPos<fMin Then fPos:=fMin;
If fPos>fMax Then fPos:=fMax;
Self.Invalidate;
End;
End;
procedure TGaugeBar.MouseMove(Shift: TShiftState; X, Y: integer);
begin
inherited;
If (Shift=[SSLeft]) Then
Begin
fPos:=X*(fMax-fMin) Div Width+fMin;
If fPos<fMin Then fPos:=fMin;
If fPos>fMax Then fPos:=fMax;
Self.Invalidate;
End;
End;
Procedure TParamsSound.CreateGaugeBar(Var AGaugeBar:TGaugeBar;Index:Cardinal; Title:String; MinVal, MaxVal:Integer);
Begin
AGaugeBar:=TGaugeBar.Create(Self);
With AGaugeBar Do
Begin
Parent:=Self;
Width:=Self.Width-10;
Left:=5;
Min:=MinVal;
Max:=MaxVal;
Pos:=(Min+Max) Div 2;
Top:=30*Index+2;
Text:=Title;
End;
End;
destructor TParamsSound.Destroy;
begin
fVolGauge.Free;
fPanGauge.Free;
fFreqGauge.Free;
fTempoGauge.Free;
inherited;
end;
Procedure TParamsSound.Paint;
begin
inherited;
Canvas.Pen.Width:=2;
Canvas.Pen.Color:=ClWhite;
Canvas.Brush.Color:=Color;
Canvas.Rectangle(ClientRect);
end;
{>>BrowserEffects}
constructor TBrowserEffects.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Color:=ClBlack;
fVSTICnt:=TEffectCnt.Create(Self);
fVSTECnt:=TEffectCnt.Create(Self);
fSoundFontCnt:=TEffectCnt.Create(Self);
fBrowserTitle:=TBrowserTitle.Create(Self);
With fBrowserTitle Do
Begin
Parent:=Self;
Top:=5;
Left:=4;
End;
fParamsSound:=TParamsSound.Create(Self);
With fParamsSound Do
Begin
Parent:=Self;
Left:=5;
Height:=122;
Top:=fBrowserTitle.Top+fBrowserTitle.Height+5;
End;
CreateButton(fAddButton,9,fParamsSound.Top+fParamsSound.Height+5,'A');
CreateButton(fDelButton,45,fParamsSound.Top+fParamsSound.Height+5,'D');
CreateButton(fActiveButton,82,fParamsSound.Top+ParamsSound.Height+5,'S');
fEffectsView:=TTreeView.Create(Self);
With fEffectsView Do
Begin
Left:=5;
Height:=105;
Width:=110;
Top:=fParamsSound.Top+fParamsSound.Height+38;
End;
end;
Procedure TBrowserEffects.Resize;
Begin
InHerited;
Width:=120;
Height:=329;
End;
Procedure TBrowserEffects.CreateButton(var Button:TBrowserButton;BtLeft,BtTop:Integer; BtCaption:String);
Begin
Button:=TBrowserButton.Create(Self);
With Button Do
Begin
Parent:=Self;
Width:=28;
Height:=28;
Left:=BtLeft;
Top:=BtTop;
Caption:=BtCaption;
Font.Size:=14;
Font.Style:=[FsBold];
Button.ColorTop:=$00FFE6E1;
Button.ColorBottom:=$00E8E8E8;
Button.ColorLine:=$0041C9D3;
End;
End;
Procedure TBrowserEffects.Create_Constantes_Nodes;
Begin
With fEffectsView Do
Begin
SndFontNode:=Items.Add(NIL,'SOUNDFONTS');
VSTINode:=Items.Add(NIL,'EFFETS VSTI');
VSTENode:=Items.Add(NIL,'EFFETS VSTE');
DSPNode:=Items.Add(NIL,'EFFETS DSP');
End;
End;
Procedure TBrowserEffects.Paint;
Begin
InHerited;
With fEffectsView Do
Begin
Parent:=Self;
Font.Color:=$00400080;
Font.Size:=6;
Color:=ClSilver;
If Items.Count=0 Then Create_Constantes_Nodes;
End;
End;
end.
Si quelqu'un sait pourquoi les propriétés des boutons, du treeview et des gauges n'apparaissent pas, je suis preneur .
cs_shining
Messages postés304Date d'inscriptionlundi 30 décembre 2002StatutMembreDernière intervention10 mars 2012 26 août 2008 à 18:29
Re-Salut Francky
Okay je crois que je viens de comprendre en tout cas après ces derniers détails !!!
et à priori je vois deux solutions possibles
le 1er:
tout au début du composant juste en dessous de " {>>TITLE}"
on met :
TOnBrowserButtonMouseDown = procedure (Sender : TObject; AButton : TBrowserButton; Button: TMouseButton; Shift: TShiftState; X, Y: Integer) of object;
note ceci n'est qu'à titre d'exemple !!( faudra complèté les autres événements)
jusque là tu me suis ?
ensuite..., dans la classe TBrowseEffects >> lisibilité en protected
Procedure TParamsSound.CreateGaugeBar(Var AGaugeBar:TGaugeBar;const AName:String;Index:Cardinal; Title:String; MinVal, MaxVal:Integer);
Begin
AGaugeBar:=TGaugeBar.Create(self);
With AGaugeBar Do
Begin
Parent:=self;
Name := AName ;
SetSubComponent(TRUE);
Width:=Self.Width-10;
Left:=5;
Min:=MinVal;
Max:=MaxVal;
Pos:=(Min+Max) Div 2;
Top:=30*Index+2;
Text:=Title;
End;
End;
Cordialement. <hr />"L'imagination est plus importante que le savoir." Albert Einstein
WhiteHippo
Messages postés1154Date d'inscriptionsamedi 14 août 2004StatutMembreDernière intervention 5 avril 20123 27 août 2008 à 08:41
Bonjour
Tu mets les noms que tu veux, l'important c'est de donner un nom aux composants afin qu'il apparaissent sous l'inspecteur d'objet et que leurs evenements associés puissent être correctement créés.
Cordialement.
<hr />"L'imagination est plus importante que le savoir." Albert Einstein
Vous n’avez pas trouvé la réponse que vous recherchez ?
cs_shining
Messages postés304Date d'inscriptionlundi 30 décembre 2002StatutMembreDernière intervention10 mars 2012 27 août 2008 à 13:13
Salut Francky ..,WhiteHippo ,
M ais c'est bien sûr !!!!, WhiteHippo est un génie !!!
même si le fait de codé le nom en dure ce n'est pas très conseillé dûs aux problèmes de conflits qu'il peut y avoir avec d'autres composants du même projet !!!
la méthode de WhiteHippo est vraiment beaucoup plus simple
constructor TBrowserButton.Create(AOwner: TComponent);
begin inherited Create(AOwner);
fClicked := False;
SetSubComponent(True);
end; ....
procedure TBrowserEffects.CreateButton(var Button : TBrowserButton ; const btLeft,btTop : Integer; const btName, btCaption : String);
begin
Button : = TBrowserButton.Create(Self);
with Button do begin
Name := btName; Parent := Self;
Width := 28;
Height := 28;
Left := btLeft;
Top := btTop;
Caption := btCaption;
Font.Size := 14;
Font.Style := [FsBold];
Button.ColorTop := $00FFE6E1;
Button.ColorBottom := $00E8E8E8;
Button.ColorLine := $0041C9D3;
end;
end;
par contre il un peu faut aérer un peut le code !!! question de lisibilité sinon
c'est impec désormais les événements apparaissent dans l'inspecteur d'objet et lors d'un clique tout marche comme sur des roulettes , à l'exception toute fois on runtime j'ai un superbe crash je suppose que ça pas partie du projet
cs_shining
Messages postés304Date d'inscriptionlundi 30 décembre 2002StatutMembreDernière intervention10 mars 2012 26 août 2008 à 16:24
Salut,
Ralala Francky un évènement ... des événements
Okay chui mal placé pour ce genre de remarque .
sinon plus sérieusement j'ai jeté un chti coup d'oeil et franchement je ne vois pas vraiment où tu veux en venir !!, je veux dire que je vois des AddButton
mais ça n'ajoute rien mais permet le changement des couleurs ? et autres... dans ce cas ça ne serait pas DefButton ? pour Valeur par Défaut
et c'est quoi le nom des classes qui sont censées représentées les événements dans l'inspecteur d'objet ?.
de plus j'ai eu un problème lors de la compilation du paquet à cause de "Procedure SetTracksGrid(Value:TTracksGrid);"
TTracksGrid <=== inconnu au bataillon dans ma version de Delphi , de plus il n'ya que l'entête mais pas le corps(partie implémentation de cette procédure), mais ce n'est pas bien grave car il suffit de mettre cette entête sous forme de comment avec // et ça compile correctement
bon un peu plus de détails serait le bienvenu si tu veux vraiment que l'on puisse te venir en aide et n'ai pas peur de nous pondre un roman
En fait tu as 3 boutons créés par la procedure CreateButton :
fAddButton:TBrowserButton; //Add est pour additionner un truc
fDelButton:TBrowserButton; //Del pour supprimer un truc
fActiveButton:TBrowserButton; //Active pour activer un truc
Quand on installe le composant dans l'insepcteur d'objet tu as 3 croix qui apparaisent avec le nom des boutons en question. Quand on clique dessus une liste déroulante apparait avec les proriétés des boutons (Couleurs, largueur, hauteur, ect ect) par contre dans la partie Evenements de l'inspecteur d'objet aucune des évenements (OnMouseDown, OnMouseMove, OnMouseUp, OnClick, OnDblClick) n'apparaissent et c'est ca que je ne comprend pas.
L'intéret est "simple" : L'idée est de pouvoir récupérer dans l'inspecteur d'objet les évenements et quand on clique dessus de voir apparaitre dans la forme
procedure TForm1.BrowserEffects1AddButtonClick(Sender: TObject);
begin
end;
C'est à dire l'équivalent de procedure TForm1.Button1Click(Sender: TObject); quand tu poses un TButton sur une form et que tu cliques dessus
Ps : * "SetTracksGrid" : Ah j'ai mal fais le ménage
*Ce que tu sous entend par classe dans mon cas, c'est de rajouter TEffectCnt = class juste apres le Type
*Pour faire simple (j'aurais du présenter les choses comme cela ) :
type
Private
fImage:TImage,
Protected
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
Property Image:TImage Read fImage Write fImage;
End;
Dans l'inspecteur tu vera les propriétés du TImage par ses évenements
@Shining : content de voir . J'avais pensé à cette solution mais ca me semblant plus du bricolage. Enfin bref j'ai pas le choix donc c'est ce que je vais faire merci
@WhiteHippo : Bien vus pour les constantes ca va obtimiser le code (et f0xi va moins raler lol). Par contre pour les strings : c'est un caption en fait et comme c'est pour controler le volume, le pan ect ect je suis pas sur que de rajouter GaugeBar soit utilie. Dis moi ce que tu en penses .
cs_shining
Messages postés304Date d'inscriptionlundi 30 décembre 2002StatutMembreDernière intervention10 mars 2012 28 août 2008 à 17:36
Salut Francky,
Citation de Francky:
«Elle est chiante c'est TextBox hein ? .»
Réponse:Ouai depuis le temps que les jean se plaignent hein !!!
Remarque pov jean tu diras .
Citation de Shining:
« c'est impec désormais les événements apparaissent dans l'inspecteur d'objet et lors d'un clique tout marche comme sur des roulettes , à l'exception toute fois en runtime j'ai un superbe crash et je suppose que ça ne fait pas partie du projet .»
Arff des scies-demons je ne suis qu'un nain-bécile .
Oui en effet en même temps j'avais télécharger Visual Studio Express 2008 qui a modifier les paramètres de Delphi concernant le JIT(just in time debogguer) mais forte heuseusement Delphi c'est plus fort que toi(Micro$oft) et après un reboot, Delphi m'a gentillement avertis que le JIT actuel n'était pas le bon . et là tout baigne , ce n'était donc pas un problème de ton source(fausse alerte donc ).
Euhh sinon désolé pour le hors-sujet mais moi ça va très bien et ça me fait plaisir de te revoir en pleine forme, c'est juste que l'an dernier j'ai accidentellement injecté du 50 volts dans mon pc via une application electronique et mon pc n'a pas trop apprécié du coup plus de carte mère , plus de disque dure, tous mes projets sont partis en fumée, du coup c'est un peu dure de reprendre la programmation , néanmoins il me reste(forte heuseurement) les vieux projets qui trainent sur code source, je ferais plus tard des mises à jour !!!
il y'a de très beaux skins souvent libres de droits(si ce n'est tous), les auteurs ne demandent qu'une chose c'est leurs noms dans le crédit ou une utilisation non commercial, sinon tu peux aussi prendre contact et faire la demande d'une autorisation spéciale.
sur ce je te souhaite une bonne continuation pour ton projet et j'attends de voir la suite car pour l'instant ça promet !!!.
«la vitesse de la lumière étant supérieur à celle du son, bien des personnes paraissent brillants jusqu'à qu'ils n'ouvrent la bouche.»(lao tseu)