From: Charlie on
Is there a method of detecting which row number is the first row displayed in
a ListView when the view has been scrolled down? There doesn't seem to be an
event that is fired when the user scrolls the list up or down. Is there
another method of detecting the top row number in the view?

Thanks,
Charlie
From: DanS on
=?Utf-8?B?Q2hhcmxpZQ==?= <Charlie(a)discussions.microsoft.com>
wrote in
news:843217DD-4384-4250-853C-4A96C5D004D7(a)microsoft.com:

> Is there a method of detecting which row number is the
> first row displayed in a ListView when the view has been
> scrolled down? There doesn't seem to be an event that is
> fired when the user scrolls the list up or down. Is there
> another method of detecting the top row number in the view?
>
> Thanks,
> Charlie
>

Blindly assuming VB6 and v6 of CommControls.......

Dim lvi as ListItem

set lvi = Listview1.GetFirstVisible()

If Not lvi is Nothing then

'lvi is set to the first visible item

End If
From: Charlie on
That worked, thanks. Now if I can just figure out how to tell if the list is
being scrolled... I'm pasting a combobox in one column, on the selected row,
much like Excel's Data Validation feature. It worked great until I scrolled
the list -- hmm, the combo didn't move with the row. :(

If there's no easy way to detect if the list is being scrolled I'll just
forget the whole feature and put the combo below the listview.

Thanks

"DanS" wrote:

> =?Utf-8?B?Q2hhcmxpZQ==?= <Charlie(a)discussions.microsoft.com>
> wrote in
> news:843217DD-4384-4250-853C-4A96C5D004D7(a)microsoft.com:
>
> > Is there a method of detecting which row number is the
> > first row displayed in a ListView when the view has been
> > scrolled down? There doesn't seem to be an event that is
> > fired when the user scrolls the list up or down. Is there
> > another method of detecting the top row number in the view?
> >
> > Thanks,
> > Charlie
> >
>
> Blindly assuming VB6 and v6 of CommControls.......
>
> Dim lvi as ListItem
>
> set lvi = Listview1.GetFirstVisible()
>
> If Not lvi is Nothing then
>
> 'lvi is set to the first visible item
>
> End If
> .
>
From: Ivar on
Or the API method :-)


Private Const LVM_FIRST As Long = &H1000
Private Const LVM_GETTOPINDEX As Long = (LVM_FIRST + 39)
Private Const LVM_GETITEMCOUNT As Long = (LVM_FIRST + 4)

Private Declare Function SendMessage Lib "user32.dll" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByRef lParam As Any) As Long


Private Function GetTopItem(LV As ListView) As Long
If SendMessage(LV.hwnd, LVM_GETITEMCOUNT, 0, 0) > 0 Then
GetTopItem = SendMessage(LV.hwnd, LVM_GETTOPINDEX, 0, 0) + 1
End If
End Function

Ivar
(Yep I still read every so often:)
From: DanS on
=?Utf-8?B?Q2hhcmxpZQ==?= <Charlie(a)discussions.microsoft.com>
wrote in
news:F0DE2342-631C-4F46-B3F0-8E8DF328AC60(a)microsoft.com:

> That worked, thanks. Now if I can just figure out how to
> tell if the list is being scrolled... I'm pasting a
> combobox in one column, on the selected row, much like
> Excel's Data Validation feature. It worked great until I
> scrolled the list -- hmm, the combo didn't move with the
> row. :(
>
> If there's no easy way to detect if the list is being
> scrolled I'll just forget the whole feature and put the
> combo below the listview.

Easy is subjective to your skill level.

I'm looking back at a project I worked on that had a multi-
column listview in it that was a d/l que. One of the sub-items
was a progress bar that is actually a pbar control that I
placed 'in' the listview using the SetParent API call, and
then I subclassed the listview for notifications sent to it by
its scroll bar.........the parent of the scroll bar is the
listview, whenever the scroll bar scrolls, it sends a
notification message to its parent (the listview) that a
scroll event happened.


The buzz word here.....subclass. There are several subclassing
controls around the internet that make it easier to do if need
be.

Once the subclass is set up, this is the call in it's
WindowProc.....


If iMsg = WM_VSCROLL Or iMsg = WM_HSCROLL Or iMsg =
WM_MOUSEWHEEL Then
CallYourSubToRepositionTheControl
End If

To me, fairly easy. It depends on your skill level.













>
> Thanks
>
> "DanS" wrote:
>
>> =?Utf-8?B?Q2hhcmxpZQ==?=
>> <Charlie(a)discussions.microsoft.com> wrote in
>> news:843217DD-4384-4250-853C-4A96C5D004D7(a)microsoft.com:
>>
>> > Is there a method of detecting which row number is the
>> > first row displayed in a ListView when the view has been
>> > scrolled down? There doesn't seem to be an event that
>> > is fired when the user scrolls the list up or down. Is
>> > there another method of detecting the top row number in
>> > the view?
>> >
>> > Thanks,
>> > Charlie
>> >
>>
>> Blindly assuming VB6 and v6 of CommControls.......
>>
>> Dim lvi as ListItem
>>
>> set lvi = Listview1.GetFirstVisible()
>>
>> If Not lvi is Nothing then
>>
>> 'lvi is set to the first visible item
>>
>> End If
>> .
>>

 |  Next  |  Last
Pages: 1 2
Prev: Looking For A New BASIC?
Next: Tom Shelton...