473,624 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5014
* "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******** ******@TK2MSFTN GP09.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.po l.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@DON T_SPAM_ME_hotma il.com> wrote in message
news:eV******** *****@tk2msftng p13.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.po l.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.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() 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.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er

'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.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
components = New System.Componen tModel.Containe r()
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.po l.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****@microso ft.com> wrote in message
news:uN******** ******@TK2MSFTN GP10.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.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() 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.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er

'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.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
components = New System.Componen tModel.Containe r()
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.po l.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
1010
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 explains how to create a DLL and implement code to disable the mouse wheel, as well as Mr. Lebans' code in MouseWheelHookA2K.zip (http://www.lebans.com/mousewheelonoff.htm), but both require a DLL. Sure, it's easy enough to run:
2
2994
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 ("Bug Fix for SubForms with ScrollBars. Bug fix for SubForms without visible ScrollBars.") - BUT I still can't get it to work on my app with my subforms. I'm using Access 2000, It works fine on the main forms but not on the
11
1656
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 record behind the form to change. Does anyone know how to control this? Thanks in advance. Billie Dee
1
1642
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 event, I believe this is to adjust the scrollbar position. This is producing undesirable results in my application and I want to disable this default behavior. Can anyone help me with this?
1
11225
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 ActiveTcl distribution to fix the crashes caused by the event. Then, I managed to see that my test script (see code below) was registering the event by printing the delta value (+/- 120). ----------------- from Tkinter import *
7
11506
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 form is visible, the vertical scroll bar of the MDI parent appears automatically. What I want to do is write a routine within the MouseWheel event of the MDI
3
3582
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 discuss the mousewheel event... but there doesn't seem to BE a mousewheel event. in VS 2003 or 2005, in C# or in VB.NET... and on the couple systems I've checked. I can't find a single control that gives me a "MouseWheel" event option in it's...
0
2484
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 receives this event and the result showed that only the top Tk widget gets it. This is really annoying. I wonder if this problem exists on other platform. I googled, but found no appliable solution, so I wrote one as following. It's not perfect,...
1
2466
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 for the detail data for each main record. The form also contains btnBegining, btnPrevious, btnNext, btnEnd. In the btnNext.MouseWheel event I can increment/decrement the main data currencymanager position of the main dataset (depending on...
0
8234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8172
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8677
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8474
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.