"Maileen" <no****@email.com> wrote
Ok, i should precised that i don't want this type of flat button because
it just make ablack border to my button...
I would like to have in fact, the button type that :
1. when mouse pointer is not on button, button is completly flat
2. when mouse pointer is over button, button style is raised
absolutely like button on Toolbar or Coolbar
You could handle it yourself, and maybe wrap up the code in a
user control (for re-use). The code below isn't all you need, but
it should get you started....
Add a label to a new form and paste in the code below:
HTH
LFS
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.ImageAlign = ContentAlignment.MiddleLeft
Label1.TextAlign = ContentAlignment.MiddleRight
Label1.Image = Me.Icon.ToBitmap
Label1.BorderStyle = BorderStyle.None
Label1.Size = New Size(70, 34)
Label1.Text = "Button "
End Sub
Private Sub Label1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseEnter
Dim Grx As Graphics = Me.CreateGraphics
ControlPaint.DrawBorder3D(Grx, New Rectangle(Label1.Left - 2, Label1.Top - 2, Label1.Width + 4, Label1.Height + 4),
Border3DStyle.RaisedInner)
Grx.Dispose()
End Sub
Private Sub Label1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseLeave
Dim Grx As Graphics = Me.CreateGraphics
ControlPaint.DrawBorder(Grx, New Rectangle(Label1.Left - 2, Label1.Top - 2, Label1.Width + 4, Label1.Height + 4),
SystemColors.Control, ButtonBorderStyle.Solid)
Grx.Dispose()
End Sub
Private Sub Label1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles
Label1.MouseDown
Dim Grx As Graphics = Me.CreateGraphics
ControlPaint.DrawBorder3D(Grx, New Rectangle(Label1.Left - 2, Label1.Top - 2, Label1.Width + 4, Label1.Height + 4),
Border3DStyle.SunkenOuter)
Grx.Dispose()
End Sub
Private Sub Label1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseUp
Dim Grx As Graphics = Me.CreateGraphics
ControlPaint.DrawBorder3D(Grx, New Rectangle(Label1.Left - 2, Label1.Top - 2, Label1.Width + 4, Label1.Height + 4),
Border3DStyle.RaisedInner)
Grx.Dispose()
End Sub