Hi,
Whenever I need to create a custom button on Visual Studio 2010, I use this code: (found in a tutorial on youtube)
Public Class BUTTON
Inherits Windows.Forms.Button
Public Sub New()
Me.Size = New System.Drawing.Point(90, 25)
Me.FlatStyle = Windows.Forms.FlatStyle.Flat
Me.BackgroundImage = My.Resources.BtnNormal
Me.BackgroundImageLayout = Windows.Forms.ImageLayout.Stretch
Me.BackColor = Drawing.Color.Transparent
Me.Font = New System.Drawing.Font("tahoma", 9.01, Drawing.FontStyle.Regular, Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ForeColor = Drawing.Color.White
Me.FlatAppearance.BorderColor = Drawing.Color.Gray
Me.FlatAppearance.MouseDownBackColor = Drawing.Color.Transparent
Me.FlatAppearance.MouseOverBackColor = Drawing.Color.Transparent
Me.FlatAppearance.BorderSize = 0
End Sub
Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
Me.BackgroundImage = My.Resources.BtnPressed
End Sub
Private Sub Button1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
Me.BackgroundImage = My.Resources.BtnHover
End Sub
Private Sub Button1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
Me.BackgroundImage = My.Resources.BtnNormal
End Sub
Private Sub Button1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
Me.BackgroundImage = My.Resources.BtnHover
End Sub
End Class
However this means that when the button is right clicked (or clicked with scroll wheel) it is also changed to the Pressed state (mouse down)
What could I add to this that would mean only left clicking the button made the mouse down state trigger?
Thanks
Whenever I need to create a custom button on Visual Studio 2010, I use this code: (found in a tutorial on youtube)
Public Class BUTTON
Inherits Windows.Forms.Button
Public Sub New()
Me.Size = New System.Drawing.Point(90, 25)
Me.FlatStyle = Windows.Forms.FlatStyle.Flat
Me.BackgroundImage = My.Resources.BtnNormal
Me.BackgroundImageLayout = Windows.Forms.ImageLayout.Stretch
Me.BackColor = Drawing.Color.Transparent
Me.Font = New System.Drawing.Font("tahoma", 9.01, Drawing.FontStyle.Regular, Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ForeColor = Drawing.Color.White
Me.FlatAppearance.BorderColor = Drawing.Color.Gray
Me.FlatAppearance.MouseDownBackColor = Drawing.Color.Transparent
Me.FlatAppearance.MouseOverBackColor = Drawing.Color.Transparent
Me.FlatAppearance.BorderSize = 0
End Sub
Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
Me.BackgroundImage = My.Resources.BtnPressed
End Sub
Private Sub Button1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
Me.BackgroundImage = My.Resources.BtnHover
End Sub
Private Sub Button1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
Me.BackgroundImage = My.Resources.BtnNormal
End Sub
Private Sub Button1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
Me.BackgroundImage = My.Resources.BtnHover
End Sub
End Class
However this means that when the button is right clicked (or clicked with scroll wheel) it is also changed to the Pressed state (mouse down)
What could I add to this that would mean only left clicking the button made the mouse down state trigger?
Thanks