Re: Help with sysListView selection

Abdel
 

Hi Alberto,

You wrote:

I tried creating an LVITEM instance (class is in sysListView32) with various mask/state/etc parameters, and passing it as 4th arguments of watchdog.cancellableSendMessage.

In fact, the fourth parameter of watchdog.cancellableSendMessage, or the second parameter of the LVM_SETITEMSTATE message, is not an instance of the LVITEM structure, but a pointer to this instance.

Here is an example for selecting all items that works here on the desktop, under a Windows-10.

It is imperative that the type of your list view is as follows:

class 'NVDAObjects.IAccessible.sysListView32.List'

For example, you can put your nav object on the first parent of the desktop window or use focus.parent.windowHandle in your console.

Once on your desktop, you open the Python console with NVDA + Control + Z.

This done, you write the following:

from NVDAObjects.IAccessible.sysListView32 import *
from watchdog import cancellableSendMessage
from ctypes import byref
# Instantiation of the LVITEM object.
lvItem = LVITEM (mask=LVIF_STATE, state=LVIS_SELECTED, stateMask=LVIS_SELECTED)
# You must then pass this instantiation as a pointer, using byref, to the cancellableSendMessage function.
cancellableSendMessage (nav.windowHandle, LVM_SETITEMSTATE, -1, byref(lvItem))

For unselecting all items you juste have to assign LVIF_STATE to the mask member and LVIS_SELECTED to stateMask as described here:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/45b14a4b-6ee8-42c4-9d94-912008931552/deselect-all-items-in-listview-c?forum=vcgeneral

However, I find that it does not always work, so it's not really reliable.

You will find a detailed description of the members of the LVITEM structure on Microsoft Doc:

https://docs.microsoft.com/en-us/windows/desktop/api/commctrl/ns-commctrl-taglvitema

Hope this helps.

Kind regards,
Abdel.


Le 05/04/2019 à 19:27, Alberto Buffolino a écrit :
Hi all,
I'm working on ColumnsReview add-on, but I have a very specific question about sysListView, so nvda-devel could be a good place too...
I'd like to select/unselect programmatically one or more list items, but it seems not so easy indeed. I found this promising page:
http://vbnet.mvps.org/index.html?code/comctl/lvselectall.htm
and so, starting from a list item and opening NVDA console, I wrote:
***
from NVDAObjects.IAccessible.sysListView32 import *
import watchdog
LVM_SETITEMSTATE = (LVM_FIRST + 43)
***
but then I don't know how to proceed exactly. I tried creating an LVITEM instance (class is in sysListView32) with various mask/state/etc parameters, and passing it as 4th arguments of
***
watchdog.cancellableSendMessage(nav.parent.windowHandle, LVM_SETITEMSTATE, -1, LVITEMInstance)
***
but even if I receive no errors, I don't see changes... and I tried and tried various solutions, with LPARAM, and so on, without success.
Do you have any suggestions?
Thanks in advance.
Alberto


Join nvda-devel@groups.io to automatically receive all group messages.