Home All Groups Group Topic Archive Search About

Using a WndProc override

Author
5 Oct 2006 8:26 PM
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

Author
5 Oct 2006 9:18 PM
rowe_newsgroups
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:
Show quoteHide quote
> 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
Author
5 Oct 2006 10:08 PM
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

Show quoteHide quote
"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
>
>
Author
6 Oct 2006 3:44 AM
Cor Ligthert [MVP]
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/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistviewclassbeginupdatetopic.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


Show quoteHide quote
"Rob" <R**@discussions.microsoft.com> schreef in bericht
news:FDF7D785-FCA6-480F-905F-590F3B3BFDF2@microsoft.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
Author
6 Oct 2006 9:09 AM
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

Show quoteHide quote
"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/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistviewclassbeginupdatetopic.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" <R**@discussions.microsoft.com> schreef in bericht
> news:FDF7D785-FCA6-480F-905F-590F3B3BFDF2@microsoft.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
>
>
>