• Listview - keep a selection when clicking a subitem ?

    From R.Wieser@21:1/5 to All on Sat Oct 1 12:45:03 2022
    Hello all,

    I've created a listview with a few columns which allows multiple rows to be selected.

    The thing is that I would like to be able to select a few rows and than
    click subitems without loosing that selection.

    I've been looking if I could ignore the LVN_SELECTIONCHANGED notification,
    but that one doesn't even return a value. And as the NM_CLICK notification comes in after all the changes its not usable either.

    tl;dr:
    Does anyone know how to keep a set of rows selected when clicking a subitem
    ?

    Or maybe the other way around : can I limit the selection of rows to only
    when clicking the main item row ?

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JJ@21:1/5 to R.Wieser on Sat Oct 1 21:16:48 2022
    On Sat, 1 Oct 2022 12:45:03 +0200, R.Wieser wrote:
    Hello all,

    I've created a listview with a few columns which allows multiple rows to be selected.

    The thing is that I would like to be able to select a few rows and than
    click subitems without loosing that selection.

    I've been looking if I could ignore the LVN_SELECTIONCHANGED notification, but that one doesn't even return a value. And as the NM_CLICK notification comes in after all the changes its not usable either.

    tl;dr:
    Does anyone know how to keep a set of rows selected when clicking a subitem
    ?

    Or maybe the other way around : can I limit the selection of rows to only when clicking the main item row ?

    Regards,
    Rudy Wieser

    Hold CTRL key for selecting more items without deselecting existing item(s).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Sat Oct 1 20:38:45 2022
    JJ,

    Hold CTRL key for selecting more items without deselecting existing
    item(s).

    I know, thats not the problem. I have the need to be able to click
    subitems (no ctrl or shift held) *without* the selection mechanism kicking
    in.

    And by the way: Have you ever tried to ctrl-click items and than click a subitem ? The selection for that row will toggle ...

    Hmm.... I just checked, for a reference, what OE6 does in such a case
    (trying to set the 'ignore' state for a set of rows). The other selected
    rows and the last (ctrl-selected) one do not change status at the same
    moment - due to that last row getting its selection toggeled when again ctrl-clicked.

    .... and that might mean that I set my goal a bit to high ....

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Sun Oct 2 10:41:37 2022
    JJ,

    Hold CTRL key for selecting more items without deselecting existing
    item(s).

    I forgot to explicitily mention that I'm using the listview in LVS_REPORT style.

    Something "funny" :

    Using a basic listview (no LVS_EX_FULLROWSELECT) you *cannot* select rows
    other than by clicking on the main items column, but clicking /anywhere/ on
    a row *will* drop the (carefull) selection you made. Go figure ...

    There might be a reason for doing it that way, but I'm not yet been able to figure it out.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JJ@21:1/5 to R.Wieser on Sun Oct 2 19:31:27 2022
    On Sun, 2 Oct 2022 10:41:37 +0200, R.Wieser wrote:

    I forgot to explicitily mention that I'm using the listview in LVS_REPORT style.

    Something "funny" :

    Using a basic listview (no LVS_EX_FULLROWSELECT) you *cannot* select rows other than by clicking on the main items column, but clicking /anywhere/ on
    a row *will* drop the (carefull) selection you made. Go figure ...

    There might be a reason for doing it that way, but I'm not yet been able to figure it out.

    Regards,
    Rudy Wieser

    Might want to try injecting CTRL key event at the correct time. e.g. when
    mouse enters the ListView and when there's existing selection.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Sun Oct 2 17:48:15 2022
    JJ,

    Might want to try injecting CTRL key event at the correct time.
    e.g. when mouse enters the ListView and when there's existing
    selection.

    I'm afraid that the/my problem already shows itself when doing the first selection and than clicking a subitem column (to effect a change al-la OE6
    with its "ignore" (spectacle icon) column). I'm confident it will do the
    same on a second selection (without my mouse having left the listview
    controls window).

    Another "funny" one : Select a few rows (using shift-click) and than do a ctrl-click afterwards (selecting a new or deselecting a currently selected row). After that there is no way to click anywhere (on a subitem or
    otherwise) to effect a change without either loosing the selection (shift-click) or unselecting the row you click (ctrl-click) and having to
    click it again to select it again. Fun when you want to toggle something
    in all of those rows ...

    I already tried to fight the selection mechanism by capturing
    LVN_ITEMCHANGING and in certain cases disallowing a change*, but than
    strange stuff started to happen when I continued ctrl-clicking rows.

    * a problem in itself, 'cause multiple changes (selected, focussed) can
    occur at the same time, and it seems to be an all-or-nothing rejection.

    Currently I've chosen to ignore, in the listviews NM_CLICK notification
    code, the ctrl/shift click on a subitem if its done on an (just switched to) unselected row. It makes sure that if a change is made its made on all rows
    at the same time.

    ... I might include a check to see if the clicked row is the only one
    selected, and than effect a non-ctrl/shift click too.

    I must say, I really enjoy working with those basic, freely configurable controls. /s

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul N@21:1/5 to R.Wieser on Tue Oct 18 06:31:30 2022
    On Saturday, October 1, 2022 at 11:45:18 AM UTC+1, R.Wieser wrote:
    Hello all,

    I've created a listview with a few columns which allows multiple rows to be selected.

    The thing is that I would like to be able to select a few rows and than click subitems without loosing that selection.

    I've been looking if I could ignore the LVN_SELECTIONCHANGED notification, but that one doesn't even return a value. And as the NM_CLICK notification comes in after all the changes its not usable either.

    tl;dr:
    Does anyone know how to keep a set of rows selected when clicking a subitem ?

    Or maybe the other way around : can I limit the selection of rows to only when clicking the main item row ?

    Just a suggestion, and I'm a bit late to the party, but... I'm guessing that the unwanted effects happen when the control receives a WM_LBUTTONDOWN message. Would it be possible to subclass the control and intercept that message? You could see what is
    being clicked on (don't know how easy that would be) and what the current state of the control is, and if the normal result is not what you want then change the message to a different one and/or do something directly.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Wed Oct 19 10:52:44 2022
    Paul,

    Would it be possible to subclass the control and intercept that message?

    At some point I was considering the same. Up until the point I realized I would be fighting the build-in selection method, and could only hope it
    would not get out on sync or have wierd side effects (i've tried some other build-in(!) stuff which did just that).

    Next to that I still needed the click event so I could do my own thing.
    That means I would either had to move code from outside the listview to
    inside it, of fake my own notification.

    In the end I decided that especially the fighting was not worth it, and setteled on not executing my own code when a subitem was clicked and (as a result) was just deselected.

    Thanks for the suggestion though.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)