Silverfrost Forums

Welcome to our forums

List view (%lv) control does not update view properly

2 Sep 2016 10:36 #17960

I have a list view control (actually several) whose definition looks like this:

	i = winio@('%^lv[full_row_select,grid_lines,user_font,show_selection_always]&',800,200,
script_data_complete,max_total_script,script_data_complete_sel,1,script_data_select)

I set the appropriate element in script_data_complete_sel to be the item I want to have appear as selected and visible in the list view box. While the item certainly will show that it is selected (if it is not visible, then if one scrolls manually through the items in the list, it can be seen grayed slightly as expected), the control does not auto-scroll to the selected item as the documentation (and show_selection_always) would suggest. I have tried performing window_update@ on the listview data, and on the selection vector, nothing seems to cause the control to show the selected item.

I'm wondering if I'm not window_update@'ing the right items, or ......

Thanks for taking a look!

3 Sep 2016 3:04 #17967

Never mind! I found the post from 2009 that discussed this and I see the issues with both my code and the control!

6 Sep 2016 6:47 #17986

Here's the link: https://forums.silverfrost.com/Forum/Topic/1129&start=0&postdays=0&postorder=asc&highlight=listview

I did a search on the term 'listview'.

6 Sep 2016 7:02 #17987

If you allow multiple selections, then the selection made will not necessarily show in the display area. I understand why that is: Do you display the first or last one? No real way to do this automatically, only programmatically.

One can select the one you wish by using a simple routine. You'll need to get the handle of the list view control using the %lc command, then call this routine with the handle and the item number (1,2,3,...) to be displayed.

	subroutine reposition_lv(wind,item)
	use mswin
	integer*4 wind
	integer*4 item,i ! item is 1 based, but the sendmessage requires zero based
	integer*4,parameter:: LVM_ENSUREVISIBLE=z'1000' + 19 ! https://www.winehq.org/pipermail/wine-devel/2002-October/009527.html
	i=sendmessage(wind,LVM_ENSUREVISIBLE,item-1,.false.) ! returns 1 for success, or 0 for failure
	return
	end
7 Sep 2016 2:29 #17991

z'1000' is the hexadecimal constant. The LVM_* commands all start at Z'1000'.

This is the same as 4096.

Again, if you make the first appear as the default, then how do you make the last appear?

Better to not make any appear if multiples are permitted and use this little ditty to show the one you want.

8 Sep 2016 3:45 #17996

That is a valid point; yet, one is still the programmer and can make that decision better for the applications purpose.

For example, I allow the user to select a disconnected list of items to edit, with an option to stop editing whenever they chose. I will highlight the last one they edited, or the last one in the list.

I also allow the user to select a disconnected set of items for deletion. I select the line closest to the first in the set, just as a default.

I could have chosen the opposite way as well. This just made sense to me based on the data presented and how the user interacts with it.

Please login to reply.