PC Review


Reply
Thread Tools Rate Thread

Button control and MouseDown/MouseUp events

 
 
Elisa
Guest
Posts: n/a
 
      17th Feb 2004
Hi,

Is it just me or does a Button control completely ignore the MouseDown
and MouseUp events??? I tried adding a handler for each event, but it
looks as if these handlers are never called...


Regards,

Elisa
 
Reply With Quote
 
 
 
 
Franky
Guest
Posts: n/a
 
      17th Feb 2004
With the HitTest method.

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwindowsformsdatagridclasshittesttopic2.asp

____________________
Franky
(E-Mail Removed)


"Elisa" <(E-Mail Removed)> wrote in message
news:A1lYb.4295$(E-Mail Removed)...
> Hi,
>
> Is it just me or does a Button control completely ignore the MouseDown
> and MouseUp events??? I tried adding a handler for each event, but it
> looks as if these handlers are never called...
>
>
> Regards,
>
> Elisa



 
Reply With Quote
 
Elisa
Guest
Posts: n/a
 
      17th Feb 2004
Hi Franky,

The URL below seems to point to something about a DataGrid.

I'm just trying to intercept the MouseDown and MouseUp events of a plain
old Button control. I even found some example source code on the web
that does much the same as I want to do, but it simply doesn't work. No
matter if I attach an event handler or overwrite the OnMouseDown or
OnMouseUp methods, it simply doesn't work. Another "feature" of the .NET
CF SP2???


Regards,

Elisa

----------

Franky wrote:

> With the HitTest method.
>
> http://msdn.microsoft.com/library/de...us/cpref/html/
> frlrfsystemwindowsformsdatagridclasshittesttopic2.asp
>
> ____________________
> Franky
> (E-Mail Removed)
>
>
> "Elisa" <(E-Mail Removed)> wrote in message
> news:A1lYb.4295$(E-Mail Removed)...
>
>>Hi,
>>
>>Is it just me or does a Button control completely ignore the MouseDown
>>and MouseUp events??? I tried adding a handler for each event, but it
>>looks as if these handlers are never called...
>>
>>
>>Regards,
>>
>>Elisa

>
>
>

 
Reply With Quote
 
Elisa
Guest
Posts: n/a
 
      17th Feb 2004
Hi,

I just found a post on Google's archive for this newsgroup, from William
Ryan:

"I'm not sure what you want to do ulitmately, but you can trap MouseDown
and MouseUp. YOu can start a timer for instance and after X intervals,
do whatever you are trying to accomplish - just make sure you stop the
timer on MouseUp."

William, have you actually tried this? What you're suggesting is exactly
what I'm doing, but it simply doesn't work!

Version 1, try overriding OnMouseDown and OnMouseUp:

-----

Imports System.Windows.Forms

Public Class RepeatButton
Inherits Button

Private WithEvents mTimer As Timer

Public Sub New()
mTimer = New Timer
mTimer.Enabled = False
mTimer.Interval = 250
End Sub

Public Property Interval() As Integer
Get
Return mTimer.Interval
End Get
Set(ByVal Value As Integer)
mTimer.Interval = Value
End Set
End Property

Private Sub OnTimer(ByVal sender As Object, ByVal e As EventArgs)
Handles mTimer.Tick
OnClick(EventArgs.Empty)
End Sub

Protected Overrides Sub OnMouseDown(ByVal e As
System.Windows.Forms.MouseEventArgs)
mTimer.Enabled = True
MyBase.OnMouseDown(e)
End Sub

Protected Overrides Sub OnMouseUp(ByVal e As
System.Windows.Forms.MouseEventArgs)
mTimer.Enabled = False
MyBase.OnMouseUp(e)
End Sub

End Class

-----

Version 2, try handling the MouseDown and MouseUp events:

-----

Imports System.Windows.Forms

Public Class RepeatButton
Inherits Button

Private WithEvents mTimer As Timer

Public Sub New()
mTimer = New Timer
mTimer.Enabled = False
mTimer.Interval = 250
End Sub

Public Property Interval() As Integer
Get
Return mTimer.Interval
End Get
Set(ByVal Value As Integer)
mTimer.Interval = Value
End Set
End Property

Private Sub OnTimer(ByVal sender As Object, ByVal e As EventArgs)
Handles mTimer.Tick
OnClick(EventArgs.Empty)
End Sub

Private Sub RepeatButton_MouseDown(ByVal sender As Object, ByVal e
As MouseEventArgs) Handles MyBase.MouseDown
mTimer.Enabled = True
End Sub

Private Sub RepeatButton_MouseUp(ByVal sender As Object, ByVal e As
MouseEventArgs) Handles MyBase.MouseUp
mTimer.Enabled = False
End Sub

End Class

-----


Regards,

Elisa
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form level MouseDown and MouseUp events don't seem to be working.... JDeats Microsoft C# .NET 1 23rd Jun 2007 11:21 AM
UserControl sending 2 MouseDown events and then a MouseUp event Mark Microsoft Dot NET Compact Framework 1 20th Apr 2006 02:51 PM
Trackbar - mouseup/mousedown events not firing. =?Utf-8?B?VmluYXk=?= Microsoft Dot NET Framework 4 30th Mar 2005 10:25 AM
MouseUp/MouseDown events for ASP.NET ImageButton Nathan Sokalski Microsoft ASP .NET 1 9th Feb 2005 07:06 AM
Question on MouseUp/MouseDown events with form buttons Colin McGuire Microsoft VB .NET 4 18th Nov 2003 07:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:33 PM.