|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Visual Basic Common Control API
Routines SendMessage: Determine a ListView's Visible Item Count |
||
Posted: | Saturday March 1, 1997 | |
Updated: | Monday December 26, 2011 | |
Applies to: | VB4-32, VB5, VB6 | |
Developed with: | VB4-32, Windows 95 | |
OS restrictions: | None | |
Author: | VBnet - Randy Birch | |
Prerequisites |
This method was tested on VB6, but should work with all
versions of the ListView Control.
Enhanced Comctl32 functionality is only available to users with comctl32.dll version 4.70 or greater installed. This dll is typically installed with IE3.x or greater. |
|
This
shows a quick call you can add to any ListView code to determine the number of currently-visible ListItems in the control when in Report
mode. By calling SendMessage with the LVM_GETCOUNTPERPAGE message, the call returns the number of items that can be completely contained in
the visible area of the list. If one becomes obscured by the horizontal scrollbar, or is partially obscured by the lower edge of the control,
it is not counted. The LVM_GETCOUNTPERPAGE message does not count (return) the actual number of row items in the control, but rather how may would be totally un-obscured if it was populated. Sending this message to an empty ListView will return a valid number representing the number of unobstructed rows that the control could contain. In addition, the message also returns the adjusted count if the ListView's HideColumnHeaders property was set to True, assuming that the newly exposed list item was totally within view. |
BAS Module Code |
None. |
|
Form Code |
Add the following code to the a form/project containing the SendMessage declare: |
|
Option Explicit '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved. ' Some pages may also contain other copyrights by the author. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Distribution: You can freely use this code in your own ' applications, but you may not reproduce ' or publish this code on any web site, ' online service, or distribute as source ' on any media without express permission. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Const LVM_FIRST As Long = &H1000 Private Const LVM_GETCOUNTPERPAGE As Long = (LVM_FIRST + 40) Private Function GetListviewVisibleCount() As Long GetListviewVisibleCount = SendMessage(ListView1.hwnd, _ LVM_GETCOUNTPERPAGE, _ 0&, _ ByVal 0&) End Function |
Comments |
Call the method such as: MsgBox "Number visible : " & GetListviewVisibleCount() |
|
|
|
|||||
|
|||||
|
|||||
Copyright ©1996-2011 VBnet and Randy Birch. All Rights Reserved. |