473,426 Members | 1,853 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,426 software developers and data experts.

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.GetLParam(GetType(NMHDR)), NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(EventArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIBLE Then
RaiseEvent VerticalScroll(Nothing, Nothing)
End If
End Sub
Oct 5 '06 #1
4 11935
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.GetLParam(GetType(NMHDR)),
NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(EventArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIBLE 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.GetLParam(GetType(NMHDR)), NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(EventArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIBLE 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_newsgroups" 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.GetLParam(GetType(NMHDR)),
NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(EventArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIBLE 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.GetLParam(GetType(NMHDR)), NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(EventArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIBLE 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*@discussions.microsoft.comschreef in bericht
news:FD**********************************@microsof t.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.GetLParam(GetType(NMHDR)), NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(EventArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIBLE 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*@discussions.microsoft.comschreef in bericht
news:FD**********************************@microsof t.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.GetLParam(GetType(NMHDR)), NMHDR)
If lParam.code = NM_HOVER Then
OnMouseHover(EventArgs.Empty)
End If
ElseIf m.Msg = LVM_ENSUREVISIBLE 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
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...
2
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...
9
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...
0
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...
0
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,...
2
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
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...
2
by: shengmin.ruan | last post by:
when i use delegate like this: ----------------- protected override void WndProc(ref Message m) { delegate_ReplyFromDataProcess = new...
6
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...
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...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.