Sign in to follow this  
Followers 0
jonny1234

Keep a running count of selected ListView items

3 posts in this topic

Hi,

I am trying to keep a running count of the selected items in a ListView. I have registered the necessary messages and the count is displayed on a label control next to the ListView when I select and de-select rows.

The problem I have discovered is that when there are many records in the ListView (e.g. 50000) and the user, whilst positioned at the first record, performs a Shift-End to select all records, then an LVN_ITEMCHANGED notification occurs for each row.

This causes the label to be updated furiously with the running count as each row is being selected, and the label becomes blurred and unreadable because it can't redraw quickly enough. If I put a "Sleep(1)" within the LVN_ITEMCHANGED event handler, then the label gets time to redraw, but it takes forever for the Shift-End to select all the rows.

What I would like to be able to do is to only update the label when the Shift-End has stopped. I can detect when it has started by checking for simultaneous Shift and End keypresses in the LVN_KEYDOWN handler, but I don't know how to check when it has completed.

I would appreciate your help on this.

Thanks,

Jonny

Share this post


Link to post
Share on other sites



Thanks for your reply.

Since posting the question I have found that, instead of using "Sleep(1)" within the LVN_ITEMCHANGED event handler, I can use:

Const $SWP_NOMOVE = 2
Const $SWP_NOSIZE = 1
Const $SWP_NOZORDER = 4
Const $SWP_DRAWFRAME = 32

DllCall("user32.dll", _
"int", "SetWindowPos", _
"hwnd", $count_label_handle, _
"hwnd", 0, _
"int", 0, _
"int", 0, _
"int", 0, _
"int", 0, _
"int", BitOR($SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOZORDER, $SWP_DRAWFRAME))

which seems to redraw the label allowing it to still be readable, and without slowing the selection process down too much.

But ideally, there would be "selection start" and "selection end" events, to allow more effective handling of the selection of large numbers of rows.

Regards,

Jonny

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0