K
Koala
Hi, I'm trying to select all listView items with SendMessage API function
and LVM_SETITEMSTATE windows message
....
hWnd = listView.handle;
index = -1;
....
LVITEM lvItem = new LVITEM();
lvItem.mask = LVIF_STATE;
lvItem.stateMask = LVIS_SELECTED;
lvItem.state = LVIS_SELECTED;
IntPtr pointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LVITEM)));
Marshal.StructureToPtr(lvItem, pointer, true);
SendMessage(hWnd, LVM_SETITEMSTATE, index, pointer);
Marshal.FreeHGlobal(pointer);
....
but this code doesn't work as it should...
it selects all items for a short while, but only after I click ListView
control with my mouse which of course move selection to the item I click on
what can be wrong? (please do not suggest other way of selecting items - I
want to do that with LVM_SETITEMSTATE message)
and LVM_SETITEMSTATE windows message
....
hWnd = listView.handle;
index = -1;
....
LVITEM lvItem = new LVITEM();
lvItem.mask = LVIF_STATE;
lvItem.stateMask = LVIS_SELECTED;
lvItem.state = LVIS_SELECTED;
IntPtr pointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LVITEM)));
Marshal.StructureToPtr(lvItem, pointer, true);
SendMessage(hWnd, LVM_SETITEMSTATE, index, pointer);
Marshal.FreeHGlobal(pointer);
....
but this code doesn't work as it should...
it selects all items for a short while, but only after I click ListView
control with my mouse which of course move selection to the item I click on
what can be wrong? (please do not suggest other way of selecting items - I
want to do that with LVM_SETITEMSTATE message)