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

API call to GetTopIndex not working for Listview (vb.net)


I'm trying to get the index of the top row in the display area of a
listview (vb.net) by doing an api call to ListView_GetTopIndex. See code
below. The call is returning a 0. The SDK doc states that
ListView_GetTopIndex "Retrieves the index of the topmost visible item
when in list or report view." The listview that I'm using is in details
view. There is no "report view" in VB.Net for listview. It apears to me
that ListView_GetTopIndex will not work with a listview in details view.

Any ideas/alternatives/help appreciated.

Dim lstvScriptsFirstVisibleRow As Int32
lstvScriptsFirstVisibleRow =
Me.ListView_GetFirstVisibleRow(lstvScripts.Handle)

Private Const LVM_FIRST = &H1000
Private Const LVM_GETCOUNTPERPAGE As Long = (LVM_FIRST + 40)
Private Const LVM_GETTOPINDEX = (LVM_FIRST + 39)
Private Declare Function SendMessage Lib "user32" Alias
"SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Int32, ByVal wParam
As Int32, ByVal lParam As Int32) As Long

Private Function ListView_GetFirstVisibleRow(ByVal hwndlv As IntPtr) As
Long
ListView_GetFirstVisibleRow = SendMessage(hwndlv,
LVM_GETTOPINDEX, 0, 0)
End Function
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
4 3159
* Henry <an*******@devdex.com> scripsit:
I'm trying to get the index of the top row in the display area of a
listview (vb.net) by doing an api call to ListView_GetTopIndex. See code
below. The call is returning a 0. The SDK doc states that
ListView_GetTopIndex "Retrieves the index of the topmost visible item
when in list or report view." The listview that I'm using is in details
view. There is no "report view" in VB.Net for listview. It apears to me
that ListView_GetTopIndex will not work with a listview in details view.

Any ideas/alternatives/help appreciated.

Dim lstvScriptsFirstVisibleRow As Int32
lstvScriptsFirstVisibleRow =
Me.ListView_GetFirstVisibleRow(lstvScripts.Handle)

Private Const LVM_FIRST = &H1000
Private Const LVM_GETCOUNTPERPAGE As Long = (LVM_FIRST + 40)
Private Const LVM_GETTOPINDEX = (LVM_FIRST + 39)
Private Declare Function SendMessage Lib "user32" Alias
"SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Int32, ByVal wParam
As Int32, ByVal lParam As Int32) As Long


Replace all 'As Long' with 'As Int32'.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet/>
Nov 20 '05 #2
Hi,

The listview has a topitem property.
http://msdn.microsoft.com/library/de...pitemtopic.asp

Ken
---------------------
"Henry" <an*******@devdex.com> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl...

I'm trying to get the index of the top row in the display area of a
listview (vb.net) by doing an api call to ListView_GetTopIndex. See code
below. The call is returning a 0. The SDK doc states that
ListView_GetTopIndex "Retrieves the index of the topmost visible item
when in list or report view." The listview that I'm using is in details
view. There is no "report view" in VB.Net for listview. It apears to me
that ListView_GetTopIndex will not work with a listview in details view.

Any ideas/alternatives/help appreciated.

Dim lstvScriptsFirstVisibleRow As Int32
lstvScriptsFirstVisibleRow =
Me.ListView_GetFirstVisibleRow(lstvScripts.Handle)

Private Const LVM_FIRST = &H1000
Private Const LVM_GETCOUNTPERPAGE As Long = (LVM_FIRST + 40)
Private Const LVM_GETTOPINDEX = (LVM_FIRST + 39)
Private Declare Function SendMessage Lib "user32" Alias
"SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Int32, ByVal wParam
As Int32, ByVal lParam As Int32) As Long

Private Function ListView_GetFirstVisibleRow(ByVal hwndlv As IntPtr) As
Long
ListView_GetFirstVisibleRow = SendMessage(hwndlv,
LVM_GETTOPINDEX, 0, 0)
End Function
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #3
Per suggestion I replaced all "longs' with int32 and I still get the
same result i.e. "0".

Changed code is below:

Dim lstvScriptsFirstVisibleRow As Int32
lstvScriptsFirstVisibleRow =
Me.ListView_GetFirstVisibleRow(lstvScripts.Handle)

Private Const LVM_FIRST = &H1000
Private Const LVM_GETCOUNTPERPAGE As Int32 = (LVM_FIRST + 40)
Private Const LVM_GETTOPINDEX = (LVM_FIRST + 39)
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal
lParam As Int32) As Int32
Private Function ListView_GetFirstVisibleRow(ByVal hwndlv As IntPtr) As
Int32
ListView_GetFirstVisibleRow = SendMessage(hwndlv, LVM_GETTOPINDEX, 0,
0)
End Function

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #4
The reason I did not use TopItem was that it was too easy.

Actually, sometimes you don't see the obvious, especially when its
staring at you right in the face. However, there are so many properties,
etc. that exist sometimes you skip right over them. That's exactly what
I did.

Topitem worked. Tks much.......

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #5

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

Similar topics

2
by: kathy | last post by:
How to call external application in .NET? For example, how to call paint.exe in VB.NET program?
2
by: Chris Michael | last post by:
Hello everybody, Newbie here. I've been working on this for the last two days and I can't figure out where this problem is. I think it's something so obvious, but I can't see it! OK, firstly...
4
by: Cyde Weys | last post by:
I'm currently working on converting a simulator program from Visual Basic 6.0 to Visual C++ .NET. I've figured out most of the stuff, but there's still one thing I haven't gotten to and I've never...
2
by: lei_xu | last post by:
Can anyone point me articles/links on sthe steps to call ActiveX from VB.net? TIA lei xu lei_xu@hotmail.com
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
1
by: Nick Gilbert | last post by:
Hi, I have just migrated my .NET 1.1 site to .NET 2.0. Most things are now working except that a lot of my images aren't displaying if they referenced the image path using ~. eg: ...
1
by: amyl | last post by:
Does anyone know of any other commericial based listview packages? I found http://www.glacialcomponents.com/. What I am looking for is one that essentially is very fast with a large amount of...
2
by: amievil | last post by:
wow... I think I'm in a trouble now. My boss is a web programmer. She said, the client asked her to develop a " dot net C" application. So, she bought Microsoft visualstudio .NET 2003 and...
5
bala2it4u
by: bala2it4u | last post by:
I am working asp.net 2003 I want to shift to 2005 ,<br>when i install it is showing a error msg that service pack 1 is required to do it ,<br> when i ask my network admin he said you want to remove...
1
by: shapper | last post by:
Hello, Does anyone knows the page of the new .NET 3.5 ListView control in MSDN? I can't find it. Thanks, Miguel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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...

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.