Voil=E0, j'avance bien ds mon control, mais j'ai un prob :
J'ai overrid=E9 les control de la souris, dont le OnMouseEnter() qui=20
change la couleur au passage de la souris.
Le prob est que sur mon panel, j'ai 2 labels entre autre, et quand le=20
curseur passe sur un label, il croit que le panel n'a plus la souris et=20
il effectue le OnMouseLeave()
Comme mon code n'est pas trop trop long, je me permet de vous le passer..=
=2E
using System;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
namespace AMPPanel
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class AMPPanel : Panel
{
AMPPanelLabelTitre ampPanelLabelTitre =3D new AMPPanelLabelTitre();
AMPPanelLabelNbObj ampPanelLabelNbObj =3D new AMPPanelLabelNbObj();
private System.Windows.Forms.PictureBox pictureBox =3D new=20
System.Windows.Forms.PictureBox();
private int NbObj =3D 0;
=09
[Category("Dossier"),
Description("(string) Affiche ou attribu le titre du dossier"),
DefaultValue("default")]
public string LeTitre
{
get
{
return ampPanelLabelTitre.Text;
}
set
{
SetTitre(value);
}
}
[Category("Dossier"),
Description("(int) Affiche ou attribu le nombre d'objet"),
DefaultValue(0)]
public int NombreObjet
{
get
{
return NbObj;
}
set
{
NbObj =3D value;
SetNbObj(NbObj);
}
}
=09
public AMPPanel() : base()
{
Name =3D "AMPPanel";
BackColor =3D System.Drawing.Color.WhiteSmoke;
BorderStyle =3D System.Windows.Forms.BorderStyle.Fixed3D;
Size =3D new System.Drawing.Size(224, 64);
Cursor =3D System.Windows.Forms.Cursors.Hand;
//
//// Picture
//
System.Resources.ResourceManager resources =3D new=20
System.Resources.ResourceManager(typeof(AMPPanel));
pictureBox.Location =3D new System.Drawing.Point(48, 48);
pictureBox.Name =3D "pictureBox1";
pictureBox.Location =3D new System.Drawing.Point(8, 8);
pictureBox.Image =3D=20
((System.Drawing.Image)(resources.GetObject("pictureBox.Image")));
//--------------------------------------------------------------------=
-
Controls.Add(ampPanelLabelTitre);
Controls.Add(ampPanelLabelNbObj);
Controls.Add(pictureBox);
}
protected class AMPPanelLabelTitre : Label
{
public AMPPanelLabelTitre()
{
Location =3D new System.Drawing.Point(72, 8);
Anchor =3D=20
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.=
Top=20
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
Cursor =3D System.Windows.Forms.Cursors.Hand;
Font =3D new System.Drawing.Font("Trebuchet MS", 9.75F,=20
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,=20
((System.Byte)(0)));
Size =3D new System.Drawing.Size(144, 16); =09
}
}
protected class AMPPanelLabelNbObj : Label
{
public AMPPanelLabelNbObj()
{
Location =3D new System.Drawing.Point(72, 24);
Anchor =3D=20
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.=
Top=20
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
Cursor =3D System.Windows.Forms.Cursors.Hand;
Font =3D new System.Drawing.Font("Trebuchet MS", 8.25F,=20
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,=20
((System.Byte)(0)));
Size =3D new System.Drawing.Size(144, 16); =09
}
}
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Julien Bakmezdjian [MS]
Bonjour,
Je pense qu'il va vous falloir jouer sur les événement MouseEnter et MouseLeave des contrôles enfants du panel. Avec un petit flag (et quelques tests pour savoir dans quel ordre ont lieu les événements), vous devriez pouvoir vous en sortir.
Autre option : lors d'un mouseLeave du panel, récupérer la position du pointeur de la souris (avec System.Windows.Forms.Cursor.Position) et la comparer au rectangle des contrôles enfants.
Cordialement,
Julien
"amplitude" a écrit dans le message de news:cft6de$kng$ Bonjour,
Voilà, j'avance bien ds mon control, mais j'ai un prob :
J'ai overridé les control de la souris, dont le OnMouseEnter() qui change la couleur au passage de la souris. Le prob est que sur mon panel, j'ai 2 labels entre autre, et quand le curseur passe sur un label, il croit que le panel n'a plus la souris et il effectue le OnMouseLeave()
Comme mon code n'est pas trop trop long, je me permet de vous le passer...
using System; using System.Windows.Forms; using System.Drawing; using System.ComponentModel;
namespace AMPPanel { /// <summary> /// Summary description for Class1. /// </summary> public class AMPPanel : Panel { AMPPanelLabelTitre ampPanelLabelTitre = new AMPPanelLabelTitre(); AMPPanelLabelNbObj ampPanelLabelNbObj = new AMPPanelLabelNbObj(); private System.Windows.Forms.PictureBox pictureBox = new System.Windows.Forms.PictureBox(); private int NbObj = 0;
[Category("Dossier"), Description("(string) Affiche ou attribu le titre du dossier"), DefaultValue("default")] public string LeTitre { get { return ampPanelLabelTitre.Text; } set { SetTitre(value); } }
[Category("Dossier"), Description("(int) Affiche ou attribu le nombre d'objet"), DefaultValue(0)] public int NombreObjet { get { return NbObj; } set { NbObj = value; SetNbObj(NbObj); } }
public AMPPanel() : base() { Name = "AMPPanel"; BackColor = System.Drawing.Color.WhiteSmoke; BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; Size = new System.Drawing.Size(224, 64); Cursor = System.Windows.Forms.Cursors.Hand; // //// Picture // System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(AMPPanel)); pictureBox.Location = new System.Drawing.Point(48, 48); pictureBox.Name = "pictureBox1"; pictureBox.Location = new System.Drawing.Point(8, 8); pictureBox.Image ((System.Drawing.Image)(resources.GetObject("pictureBox.Image"))); //--------------------------------------------------------------------- Controls.Add(ampPanelLabelTitre); Controls.Add(ampPanelLabelNbObj); Controls.Add(pictureBox); }
protected class AMPPanelLabelTitre : Label { public AMPPanelLabelTitre() { Location = new System.Drawing.Point(72, 8); Anchor ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); Cursor = System.Windows.Forms.Cursors.Hand; Font = new System.Drawing.Font("Trebuchet MS", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); Size = new System.Drawing.Size(144, 16); } }
protected class AMPPanelLabelNbObj : Label { public AMPPanelLabelNbObj() { Location = new System.Drawing.Point(72, 24); Anchor ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); Cursor = System.Windows.Forms.Cursors.Hand; Font = new System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); Size = new System.Drawing.Size(144, 16); } }
Je pense qu'il va vous falloir jouer sur les événement MouseEnter et
MouseLeave des contrôles enfants du panel. Avec un petit flag (et quelques
tests pour savoir dans quel ordre ont lieu les événements), vous devriez
pouvoir vous en sortir.
Autre option : lors d'un mouseLeave du panel, récupérer la position du
pointeur de la souris (avec System.Windows.Forms.Cursor.Position) et la
comparer au rectangle des contrôles enfants.
Cordialement,
Julien
"amplitude" <news@ampBLOUdesign.net> a écrit dans le message de
news:cft6de$kng$1@apollon.grec.isp.9tel.net...
Bonjour,
Voilà, j'avance bien ds mon control, mais j'ai un prob :
J'ai overridé les control de la souris, dont le OnMouseEnter() qui
change la couleur au passage de la souris.
Le prob est que sur mon panel, j'ai 2 labels entre autre, et quand le
curseur passe sur un label, il croit que le panel n'a plus la souris et
il effectue le OnMouseLeave()
Comme mon code n'est pas trop trop long, je me permet de vous le passer...
using System;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
namespace AMPPanel
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class AMPPanel : Panel
{
AMPPanelLabelTitre ampPanelLabelTitre = new AMPPanelLabelTitre();
AMPPanelLabelNbObj ampPanelLabelNbObj = new AMPPanelLabelNbObj();
private System.Windows.Forms.PictureBox pictureBox = new
System.Windows.Forms.PictureBox();
private int NbObj = 0;
[Category("Dossier"),
Description("(string) Affiche ou attribu le titre du dossier"),
DefaultValue("default")]
public string LeTitre
{
get
{
return ampPanelLabelTitre.Text;
}
set
{
SetTitre(value);
}
}
[Category("Dossier"),
Description("(int) Affiche ou attribu le nombre d'objet"),
DefaultValue(0)]
public int NombreObjet
{
get
{
return NbObj;
}
set
{
NbObj = value;
SetNbObj(NbObj);
}
}
public AMPPanel() : base()
{
Name = "AMPPanel";
BackColor = System.Drawing.Color.WhiteSmoke;
BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
Size = new System.Drawing.Size(224, 64);
Cursor = System.Windows.Forms.Cursors.Hand;
//
//// Picture
//
System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(AMPPanel));
pictureBox.Location = new System.Drawing.Point(48, 48);
pictureBox.Name = "pictureBox1";
pictureBox.Location = new System.Drawing.Point(8, 8);
pictureBox.Image ((System.Drawing.Image)(resources.GetObject("pictureBox.Image")));
//---------------------------------------------------------------------
Controls.Add(ampPanelLabelTitre);
Controls.Add(ampPanelLabelNbObj);
Controls.Add(pictureBox);
}
protected class AMPPanelLabelTitre : Label
{
public AMPPanelLabelTitre()
{
Location = new System.Drawing.Point(72, 8);
Anchor ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
Cursor = System.Windows.Forms.Cursors.Hand;
Font = new System.Drawing.Font("Trebuchet MS", 9.75F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
Size = new System.Drawing.Size(144, 16);
}
}
protected class AMPPanelLabelNbObj : Label
{
public AMPPanelLabelNbObj()
{
Location = new System.Drawing.Point(72, 24);
Anchor ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
Cursor = System.Windows.Forms.Cursors.Hand;
Font = new System.Drawing.Font("Trebuchet MS", 8.25F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
Size = new System.Drawing.Size(144, 16);
}
}
Je pense qu'il va vous falloir jouer sur les événement MouseEnter et MouseLeave des contrôles enfants du panel. Avec un petit flag (et quelques tests pour savoir dans quel ordre ont lieu les événements), vous devriez pouvoir vous en sortir.
Autre option : lors d'un mouseLeave du panel, récupérer la position du pointeur de la souris (avec System.Windows.Forms.Cursor.Position) et la comparer au rectangle des contrôles enfants.
Cordialement,
Julien
"amplitude" a écrit dans le message de news:cft6de$kng$ Bonjour,
Voilà, j'avance bien ds mon control, mais j'ai un prob :
J'ai overridé les control de la souris, dont le OnMouseEnter() qui change la couleur au passage de la souris. Le prob est que sur mon panel, j'ai 2 labels entre autre, et quand le curseur passe sur un label, il croit que le panel n'a plus la souris et il effectue le OnMouseLeave()
Comme mon code n'est pas trop trop long, je me permet de vous le passer...
using System; using System.Windows.Forms; using System.Drawing; using System.ComponentModel;
namespace AMPPanel { /// <summary> /// Summary description for Class1. /// </summary> public class AMPPanel : Panel { AMPPanelLabelTitre ampPanelLabelTitre = new AMPPanelLabelTitre(); AMPPanelLabelNbObj ampPanelLabelNbObj = new AMPPanelLabelNbObj(); private System.Windows.Forms.PictureBox pictureBox = new System.Windows.Forms.PictureBox(); private int NbObj = 0;
[Category("Dossier"), Description("(string) Affiche ou attribu le titre du dossier"), DefaultValue("default")] public string LeTitre { get { return ampPanelLabelTitre.Text; } set { SetTitre(value); } }
[Category("Dossier"), Description("(int) Affiche ou attribu le nombre d'objet"), DefaultValue(0)] public int NombreObjet { get { return NbObj; } set { NbObj = value; SetNbObj(NbObj); } }
public AMPPanel() : base() { Name = "AMPPanel"; BackColor = System.Drawing.Color.WhiteSmoke; BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; Size = new System.Drawing.Size(224, 64); Cursor = System.Windows.Forms.Cursors.Hand; // //// Picture // System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(AMPPanel)); pictureBox.Location = new System.Drawing.Point(48, 48); pictureBox.Name = "pictureBox1"; pictureBox.Location = new System.Drawing.Point(8, 8); pictureBox.Image ((System.Drawing.Image)(resources.GetObject("pictureBox.Image"))); //--------------------------------------------------------------------- Controls.Add(ampPanelLabelTitre); Controls.Add(ampPanelLabelNbObj); Controls.Add(pictureBox); }
protected class AMPPanelLabelTitre : Label { public AMPPanelLabelTitre() { Location = new System.Drawing.Point(72, 8); Anchor ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); Cursor = System.Windows.Forms.Cursors.Hand; Font = new System.Drawing.Font("Trebuchet MS", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); Size = new System.Drawing.Size(144, 16); } }
protected class AMPPanelLabelNbObj : Label { public AMPPanelLabelNbObj() { Location = new System.Drawing.Point(72, 24); Anchor ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); Cursor = System.Windows.Forms.Cursors.Hand; Font = new System.Drawing.Font("Trebuchet MS", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); Size = new System.Drawing.Size(144, 16); } }