473,385 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

disabling mousewheel on conbobox

There are references to using the wndproc form sub to trap and swallow the
mousewheeel events - but they don't get there when a combobox (or many other
controls) has the focus.. Yet the MSDN does suggest this is a way to stop
the mousewheel scrolling a combobox

anyone know the REAL answer???

Thanks
Roger
Nov 20 '05 #1
6 5002
* "Roger Uribe" <ne**@roger-u.fsnet.co.uk> scripsit:
There are references to using the wndproc form sub to trap and swallow the
mousewheeel events - but they don't get there when a combobox (or many other
controls) has the focus.. Yet the MSDN does suggest this is a way to stop
the mousewheel scrolling a combobox


I am interested to know /why/ you want to do that.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #2
why!! because it is far far too easy to accidentally change the selection.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eo**************@TK2MSFTNGP09.phx.gbl...
* "Roger Uribe" <ne**@roger-u.fsnet.co.uk> scripsit:
There are references to using the wndproc form sub to trap and swallow the mousewheeel events - but they don't get there when a combobox (or many other controls) has the focus.. Yet the MSDN does suggest this is a way to stop the mousewheel scrolling a combobox


I am interested to know /why/ you want to do that.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 20 '05 #3
amen

I used to have a webform with an autopostback dropdown. Found out when
people used the mouse wheel to scroll the page, it would cause the postback
on the dropdown if that was where the focus was. Grrrr...

Greg

"Roger Uribe" <ne**@roger-u.fsnet.co.uk> wrote in message
news:cd**********@news5.svr.pol.co.uk...
why!! because it is far far too easy to accidentally change the selection.

Nov 20 '05 #4
so... somebody, somewhere MUST know how to prevent it - not on web forms,
bit in a vb.net app surely

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eV*************@tk2msftngp13.phx.gbl...
amen

I used to have a webform with an autopostback dropdown. Found out when
people used the mouse wheel to scroll the page, it would cause the postback on the dropdown if that was where the focus was. Grrrr...

Greg

"Roger Uribe" <ne**@roger-u.fsnet.co.uk> wrote in message
news:cd**********@news5.svr.pol.co.uk...
why!! because it is far far too easy to accidentally change the

selection.


Nov 20 '05 #5
If you are trying to capture the mouse wheel event in the WndProc of the
form, then you're right - when the focus is on the combobox the mousewheel
events dont seem to be passed to the form which is why they don't appear in
the WndProc of the form. However, the event is still fired since that is how
the selection is being changed. In order to eat up the mouse wheel events in
a combobox, you'll have to create a custom control that inherits from the
combobox (I'm not sure of "have to" but thats what I found working :)).
Within the control, you can override the control's WndProc and eat up the
mouse wheel messages. Here's what my control looks like:

Public Class UserControl1
Inherits System.Windows.Forms.ComboBox

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'UserControl1 overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

#End Region

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case &H20A
Debug.WriteLine("mouse wheel on combo")
Case Else
MyBase.WndProc(m)
End Select
End Sub
End Class

Just build a control class library containing this control. For testing
purposes, have your project and this control class library in the same
project and then add the control to your form from the designer (you should
see the new control under 'My User Controls' instead of 'Windows Forms' in
the toolbox). Just add a couple of items to the combo and run your project.
Try your mouse scroll on the user control and voila! you should have them
'eaten' up..

hope this helps..
Imran.

"Roger Uribe" <ne**@roger-u.fsnet.co.uk> wrote in message
news:cd*********@newsg1.svr.pol.co.uk...
There are references to using the wndproc form sub to trap and swallow the
mousewheeel events - but they don't get there when a combobox (or many other controls) has the focus.. Yet the MSDN does suggest this is a way to stop
the mousewheel scrolling a combobox

anyone know the REAL answer???

Thanks
Roger

Nov 20 '05 #6
Excellent!!!!!!!!!!!!!!!!
I had a few unexpected problems renaming it from UserControl1 to myComboBox
but that apart the principle works brilliantly

Thank-you
Roger
"Imran Koradia" <no****@microsoft.com> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
If you are trying to capture the mouse wheel event in the WndProc of the
form, then you're right - when the focus is on the combobox the mousewheel
events dont seem to be passed to the form which is why they don't appear in the WndProc of the form. However, the event is still fired since that is how the selection is being changed. In order to eat up the mouse wheel events in a combobox, you'll have to create a custom control that inherits from the
combobox (I'm not sure of "have to" but thats what I found working :)).
Within the control, you can override the control's WndProc and eat up the
mouse wheel messages. Here's what my control looks like:

Public Class UserControl1
Inherits System.Windows.Forms.ComboBox

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'UserControl1 overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub

#End Region

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Select Case m.Msg
Case &H20A
Debug.WriteLine("mouse wheel on combo")
Case Else
MyBase.WndProc(m)
End Select
End Sub
End Class

Just build a control class library containing this control. For testing
purposes, have your project and this control class library in the same
project and then add the control to your form from the designer (you should see the new control under 'My User Controls' instead of 'Windows Forms' in
the toolbox). Just add a couple of items to the combo and run your project. Try your mouse scroll on the user control and voila! you should have them
'eaten' up..

hope this helps..
Imran.

"Roger Uribe" <ne**@roger-u.fsnet.co.uk> wrote in message
news:cd*********@newsg1.svr.pol.co.uk...
There are references to using the wndproc form sub to trap and swallow the mousewheeel events - but they don't get there when a combobox (or many

other
controls) has the focus.. Yet the MSDN does suggest this is a way to stop the mousewheel scrolling a combobox

anyone know the REAL answer???

Thanks
Roger


Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: deko | last post by:
Is it possible to disable the mouse wheel WITHOUT using a DLL? I've looked at Microsoft Knowledge Base Article 278379 (http://support.microsoft.com/default.aspx?scid=kb;en-us;278379), which...
2
by: Jack | last post by:
Hi all, I searched the archives and found everyone happy with Stephen's MouseWheel On/Off code except for those with subforms. Stephen's page indicates that he has added code to handle subforms...
11
by: Billie Dee | last post by:
I am currently using (and loving) Lebans MouseWheelOnOff (v22). My problem is that if the user clicks an option box suddenly the mousewheel allows scrolling on the form again. This is causing the...
1
by: Jon | last post by:
I have written a custom event handler for the mousewheel event, but in addition to my custom event handler code, the default event handler behavior is still being executed. For the mousewheel...
1
by: Nicholas Shewmaker | last post by:
(I apologize if this posts twice. My AVG is being fussy.) From what I've read, MouseWheel is a very tricky event. I have replaced my Python tcl84.dll and tk84.dll files with those in the...
7
by: James | last post by:
Hi, I have a Windows Forms application which uses multiple child forms (MDI interface). The height of one of the child forms is larger than the height of the MDI client area, so when this...
3
by: Dave K | last post by:
I seem to be missing something... I want to use a mousewheel event in my VB.NET app... and there's a lot of example code on the net showing how to use the mousewheel event... and the .NET docs...
0
by: WaterWalk | last post by:
Hello. When I tried to make Tkinter canvas widget respond to MouseWheel event on Windows XP, I failed. The canvas just doesn't receive MouseWheel event. I used bind_all to find out which widget...
1
by: =?Utf-8?B?UmljaA==?= | last post by:
In a database search application (vb2005), the user wants to be able to scroll through records using the mousewheel. The data display form contains textboxes for the main data and a datagridview...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.