jo0ls <sp**@example.invalid> wrote in news:EvLOd.11291$8B3.8157
@text.news.blueyonder.co.uk:
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in
news:eo**************@TK2MSFTNGP12.phx.gbl:
"whoopding" <vb@whoopding.com> schrieb: Use Button1_Click and Button1_DoubleClick events procedures
Still, for every 'DoubleClick' event a 'Click' event is fired too.
hmm doubleclick never fires anyway:
"This member supports the .NET Framework infrastructure and is not
intended to be used directly from your code."
so a custom button to capture clicks:
Private Class dblClickButton
Inherits System.Windows.Forms.Button
Public noOfClicks As Integer = 0
Public ReadOnly Property [Clicks]() As Integer
Get
Return noOfClicks
End Get
End Property
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = &H201 Then noOfClicks = 1
If m.Msg = &H203 Then noOfClicks = 2
MyBase.WndProc(m)
End Sub
End Class
Those hex values used to be listed in the winuser.h file in the sdk but
have dissapeared.
&H201 occurs when it's a single click
&H203 occurs when it's a double clik
we still want them processed so feed them back with mybase.wndproc(m)
With the new base button you can catch the single and double clicks:
Dim WithEvents btn1 As New dblClickButton
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
btn1.Location = New System.Drawing.Point(150, 100)
Me.Controls.Add(btn1)
btn1.Text = "click me"
End Sub
Private Sub btn1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn1.Click
Me.Label1.Text = Me.btn1.Clicks
End Sub
BUT, it will still catch a single click just before each double click
fires, but at least it does know if a double click occured.