Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
List View Contribution
Message
From
23/10/1998 15:23:44
Bob Lucas
The WordWare Agency
Alberta, Canada
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
List View Contribution
Miscellaneous
Thread ID:
00149975
Message ID:
00149975
Views:
51
I don't know about you, but I have found list views kind of a pain because only the first column could be clicked on or selected. What I didn't realize was that the listview supports much more than this, but didn't expose these properties and methods in the OCX. Naughty, naughty!

However, I have a quick and easy method to highlight the whole list line, to allow selection at any point, and to allow highlighting just by having the mouse pointer hovering on a line.

This stuff is just too good not to share!

The code has not been cleaned up, but it works! Some is not necessary. So? Delete what you don't need.

Add a list view to a form. Name it oleListView and then add this code to the init of the form. Also add three headers to the list view (using properties and right-click on the Listview control.) set the width to 100 for each header.

#DEFINE LVM_FIRST = 0x1000
#DEFINE LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54
#DEFINE LVS_EX_GRIDLINES = 0x1
#DEFINE LVS_EX_SUBITEMIMAGES = 0x2
#DEFINE LVS_EX_CHECKBOXES = 0x4
#DEFINE LVS_EX_TRACKSELECT = 0x8
#DEFINE LVS_EX_HEADERDRAGDROP = 0x10
#DEFINE LVS_EX_FULLROWSELECT = 0x20 && applies to report mode only
#DEFINE LVS_EX_ONECLICKACTIVATE = 0x40
#DEFINE LVS_EX_TWOCLICKACTIVATE = 0x80


Declare INTEGER SendMessage IN user32.dll ;
integer hwnd, integer wMsg, Integer wParam, integer lParam

Declare Integer FindWindowEx IN user32 ;
integer hWnd1, integer hWnd2 , string lpsz1, string lpsz2
Declare integer GetSystemMetrics In user32 integer nIndex

a = thisform.OleListView.hwnd
b = 0x1000 + 54
c = BITOR(0x20, 0x8)

Result = SendMessage(a, b, c, c)

* Result = SendMessage(a, b, c, c)


thisform.OleListView.View = 3

lo = thisform.OleListView.ListItems.Add(,"Key1","this is the first item",0,0)

lo.SubItems(1) = "Fruit"

lo.SubItems(2) = "Oranges"
lo = thisform.OleListView.ListItems.Add(,"Key2","Select here for item two",0,0)

lo.SubItems(1) = "Vegetable"

lo.SubItems(2) = "Potato"

lo = thisform.OleListView.ListItems.Add(,"Key3","Last item in list",0,0)

lo.SubItems(1) = "Soup"

lo.SubItems(2) = "Chicken Noodle"
Next
Reply
Map
View

Click here to load this message in the networking platform