VB and VBA Users Source Code: Setting the Full Line Style of a Report Listview
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Setting the Full Line Style of a Report Listview
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Wednesday, November 14, 2001
Hits:
655
Category:
Windows API
Article:
The following code sets the full line style property of a listview. Note, used for mostly for "Microsoft Windows Common Controls 5.0" as this didn't expose the full line select property. Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Const LVM_FIRST = &H1000, LVM_GETNEXTITEM = (LVM_FIRST + 12) Private Const LVNI_SELECTED = &H2, LVM_GETSELECTEDCOUNT = (LVM_FIRST + 50) Private Const LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54, LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55 Private Const LVS_EX_FULLROWSELECT = &H20 'Purpose : Sets the line style of a listview. 'Inputs : bFullLineStyle If True the listview will select full rows, else will select first row ' oLV The listview to set the full line style on. 'Outputs : Returns True if an error occurred 'Author : Andrew Baker 'Date : 23/07/2000 20:00 'Notes : Used for "Microsoft Windows Common Controls 5.0" as this didn't expose the full line select property. Requires the "View" property to be set to "lvwReport". 'Revisions : Function LVFullLineStyle(bFullLineStyle As Boolean, lLVHwnd As Long) As Boolean Dim lRetVal As Long, lStyle As Long On Error GoTo ErrFailed lStyle = SendMessageLong(lLVHwnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0&, 0&) If bFullLineStyle Then 'Set Full Row style bit lStyle = lStyle Or LVS_EX_FULLROWSELECT Else 'Remove Full Row style bit lStyle = lStyle Xor LVS_EX_FULLROWSELECT End If lRetVal = SendMessageLong(lLVHwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0&, lStyle) Exit Function ErrFailed: LVFullLineStyle = True End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder