473,625 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using a WndProc override

Rob
I've constructed a user control inherited from ListView so I can handle and
respond to scrolling events (to keep 2 listviews scrolling in sync).

My user control includes an Overrides of WndProc (I've attached the code at
the end of this mail). Is it possible to 'disable' this override until I need
it - it's just when I populate the ListViews this sub is called repeatadly.
What I'd like to do is populate the listviews and then 'enable' this override
to catch and trigger a scrolling event.

tia

Rob

Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc( m)
If m.Msg = WM_VSCROLL OrElse m.Msg = WM_MOUSEWHEEL Then
RaiseEvent VerticalScroll( Nothing, Nothing)
ElseIf m.Msg = WM_NOTIFY Then
Dim lParam As NMHDR = CType(m.GetLPar am(GetType(NMHD R)), NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(Ev entArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIB LE Then
RaiseEvent VerticalScroll( Nothing, Nothing)
End If
End Sub
Oct 5 '06 #1
4 12006
Use a boolean variable or property.

Private MyBool as boolean = false

Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc( m)
if MyBool = true then
If m.Msg = WM_VSCROLL OrElse m.Msg = WM_MOUSEWHEEL Then
RaiseEvent VerticalScroll( Nothing, Nothing)
ElseIf m.Msg = WM_NOTIFY Then
Dim lParam As NMHDR = CType(m.GetLPar am(GetType(NMHD R)),
NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(Ev entArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIB LE Then
RaiseEvent VerticalScroll( Nothing, Nothing)
End If
end if
End Sub
Rob wrote:
I've constructed a user control inherited from ListView so I can handle and
respond to scrolling events (to keep 2 listviews scrolling in sync).

My user control includes an Overrides of WndProc (I've attached the code at
the end of this mail). Is it possible to 'disable' this override until I need
it - it's just when I populate the ListViews this sub is called repeatadly.
What I'd like to do is populate the listviews and then 'enable' this override
to catch and trigger a scrolling event.

tia

Rob

Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc( m)
If m.Msg = WM_VSCROLL OrElse m.Msg = WM_MOUSEWHEEL Then
RaiseEvent VerticalScroll( Nothing, Nothing)
ElseIf m.Msg = WM_NOTIFY Then
Dim lParam As NMHDR = CType(m.GetLPar am(GetType(NMHD R)), NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(Ev entArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIB LE Then
RaiseEvent VerticalScroll( Nothing, Nothing)
End If
End Sub
Oct 5 '06 #2
Rob
Thanks - I was really wondering if there was an equivalent to the
Addhandler/Removehandler event approach to bypass the call to the sub
completely (until I was ready).
r

"rowe_newsgroup s" wrote:
Use a boolean variable or property.

Private MyBool as boolean = false

Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc( m)
if MyBool = true then
If m.Msg = WM_VSCROLL OrElse m.Msg = WM_MOUSEWHEEL Then
RaiseEvent VerticalScroll( Nothing, Nothing)
ElseIf m.Msg = WM_NOTIFY Then
Dim lParam As NMHDR = CType(m.GetLPar am(GetType(NMHD R)),
NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(Ev entArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIB LE Then
RaiseEvent VerticalScroll( Nothing, Nothing)
End If
end if
End Sub
Rob wrote:
I've constructed a user control inherited from ListView so I can handle and
respond to scrolling events (to keep 2 listviews scrolling in sync).

My user control includes an Overrides of WndProc (I've attached the code at
the end of this mail). Is it possible to 'disable' this override until I need
it - it's just when I populate the ListViews this sub is called repeatadly.
What I'd like to do is populate the listviews and then 'enable' this override
to catch and trigger a scrolling event.

tia

Rob

Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc( m)
If m.Msg = WM_VSCROLL OrElse m.Msg = WM_MOUSEWHEEL Then
RaiseEvent VerticalScroll( Nothing, Nothing)
ElseIf m.Msg = WM_NOTIFY Then
Dim lParam As NMHDR = CType(m.GetLPar am(GetType(NMHD R)), NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(Ev entArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIB LE Then
RaiseEvent VerticalScroll( Nothing, Nothing)
End If
End Sub

Oct 5 '06 #3
Rob,

The listview has a property used to disable scrolling or whatever during
looding, because that can take a lot of time. It is one of the few controls
which has that.

https://msdn.microsoft.com/library/d...pdatetopic.asp

Is it not better to use that, than an Win32 method from which you don't know
if it will be in future or other OS versions?

Cor
"Rob" <Ro*@discussion s.microsoft.com schreef in bericht
news:FD******** *************** ***********@mic rosoft.com...
I've constructed a user control inherited from ListView so I can handle
and
respond to scrolling events (to keep 2 listviews scrolling in sync).

My user control includes an Overrides of WndProc (I've attached the code
at
the end of this mail). Is it possible to 'disable' this override until I
need
it - it's just when I populate the ListViews this sub is called
repeatadly.
What I'd like to do is populate the listviews and then 'enable' this
override
to catch and trigger a scrolling event.

tia

Rob

Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc( m)
If m.Msg = WM_VSCROLL OrElse m.Msg = WM_MOUSEWHEEL Then
RaiseEvent VerticalScroll( Nothing, Nothing)
ElseIf m.Msg = WM_NOTIFY Then
Dim lParam As NMHDR = CType(m.GetLPar am(GetType(NMHD R)), NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(Ev entArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIB LE Then
RaiseEvent VerticalScroll( Nothing, Nothing)
End If
End Sub

Oct 6 '06 #4
Rob
Thanks

I need the user control and use of wndproc to support the lack of a
scrolling event for the listview (after population). With the wndproc
override I'm trapping most of the user scroll actions and raising an event
which allows me to synchronise the scrolling between this listview and
another listview (using topitem) - to give me 'compare side by side' ala
Excel/Word type functionality.

It's not a big deal but whenever I do something (like add an item) to either
listivew then the wndproc override is triggered. I would like to surpress the
override until I need it (ie after I've populated both views).

I've got a beginupdate and endupdate settings around the population.

thanks again
Rob

"Cor Ligthert [MVP]" wrote:
Rob,

The listview has a property used to disable scrolling or whatever during
looding, because that can take a lot of time. It is one of the few controls
which has that.

https://msdn.microsoft.com/library/d...pdatetopic.asp

Is it not better to use that, than an Win32 method from which you don't know
if it will be in future or other OS versions?

Cor
"Rob" <Ro*@discussion s.microsoft.com schreef in bericht
news:FD******** *************** ***********@mic rosoft.com...
I've constructed a user control inherited from ListView so I can handle
and
respond to scrolling events (to keep 2 listviews scrolling in sync).

My user control includes an Overrides of WndProc (I've attached the code
at
the end of this mail). Is it possible to 'disable' this override until I
need
it - it's just when I populate the ListViews this sub is called
repeatadly.
What I'd like to do is populate the listviews and then 'enable' this
override
to catch and trigger a scrolling event.

tia

Rob

Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc( m)
If m.Msg = WM_VSCROLL OrElse m.Msg = WM_MOUSEWHEEL Then
RaiseEvent VerticalScroll( Nothing, Nothing)
ElseIf m.Msg = WM_NOTIFY Then
Dim lParam As NMHDR = CType(m.GetLPar am(GetType(NMHD R)), NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(Ev entArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIB LE Then
RaiseEvent VerticalScroll( Nothing, Nothing)
End If
End Sub


Oct 6 '06 #5

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

Similar topics

2
8914
by: Martin Müller | last post by:
Hi folks! I have a .NET RichTextBox derived class which has to react differently to WM_GETTEXT (and some other messages) than it does by default (mainly converting between \n and \r\n). I override WndProc, but returning the (altered) text does not work: protected override void WndProc(ref System.Windows.Forms.Message m) { switch (m.Msg)
2
21456
by: Ed Sutton | last post by:
How can a WndProc be created inside a component? Currently I have a WndProc in my frmMain. It looks for WM_DEVICECHANGE messages for connection and removal events for a USB/Serial device. My frmMain uses a component to communicate with a USB/Serial device. I would prefer that this component handle the WM_DEVICECHANGE messages internally and only fires events to my frmMain when my USB device connects or disconnects. In case anyone...
9
3956
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it will not set the value of the control and will leave the checked status of the checkbox to false when a user selects a new date. this works fine when using the control on a win2k machine but if we use it on a win XP box and call
0
2174
by: Marco Segurini | last post by:
Hi, I am trying to dynamically install/deinstall a message handler to a System.Windows.Forms.Form using NativeWindow. I do not use IMessageFilter derived class because it intercept only the PostMessage messages. My problem is that when I install the message handler the second time a "Fatal stack overflow error" occurs.
0
4107
by: han.phony | last post by:
Hi, I am trying to intercept the message sent back by winmm.dll's mciSendString method when playback is finished. I tried to override the WndProc in the form but I didn't get/intercept the message, here is the code fragment: public const int MM_MCINOTIFY = 953; public const int MM_NOTIFY_ABORTED = 4; public const int MCI_NOTIFY_FAILURE = 8; public const int MCI_NOTIFY_SUCCESSFUL = 1; public const int MCI_NOTIFY_SUPERSEDED = 2;
2
2457
by: dworthem | last post by:
if I have the compiler option /clr:oldSyntax in a Windows Forms application protected: void WndProc(System::Windows::Forms::Message* m) is called If I remove oldSyntax protected:
2
3917
by: Derrick | last post by:
Hello all; I'm trying to create a UI that's a little atypical. In the main form's Paint event handler, I draw an image on the form - this is what I want to by my "real" UI. I turned off the form border, and set the form's background and transparency key to be the same value. As you know, because of this there is no sign of the form, just the image I painted. So far, so good. Since the form border - and hence the title bar - is...
2
4105
by: shengmin.ruan | last post by:
when i use delegate like this: ----------------- protected override void WndProc(ref Message m) { delegate_ReplyFromDataProcess = new PrepareDelegate_ReplyFromDataProcess(ReplyFromDataProcess);
6
4721
by: --== Alain ==-- | last post by:
Hi, How can i do if i want to subclass WndProc from a control to MyNewWndProc ? in fact i have a UserControl on which i have another control (ListVire). And i want to subclass the WndProc of ListView by MyNewWndProc function from my UserControl. thx.
0
8251
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
8182
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
8688
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...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8494
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...
1
6115
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
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4085
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...
1
2614
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.