Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 384
  • Last Modified:

How to select an item in a listview which allows only 1 selected item at a time

Hello. I've been trying to select an item on an external listview but it seems to only work with listviews that accept multiple selected items:
HANDLE process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, 0xC30); 
 
LVITEM lvi;
 
LVITEM* _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE); 
 
 lvi.state = LVIS_FOCUSED | LVIS_SELECTED;
 lvi.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
 lvi.mask = LVIF_STATE;
 
 WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL); 
 int abc = ::SendMessage((HWND)0x00080D6A, LVM_SETITEMSTATE, (WPARAM)0, (LPARAM)_lvi); 
 VirtualFreeEx(process, _lvi, 0, MEM_RELEASE);

Open in new window

0
devoured_elysium
Asked:
devoured_elysium
  • 2
1 Solution
 
pgnatyukCommented:
Will this way with SendMessage work, if the listview will be in the current process?
There were always few steps - give focus to the listview, select the item, check that this item is visible. seems like you didn't switch the focus? or just didn't redraw the list?
0
 
pgnatyukCommented:
In a common case it can be like that:
ListView_SetItemState(hList, -1, 0, LVIS_SELECTED);
SendMessage(hList,LVM_ENSUREVISIBLE,  (WPARAM)item, FALSE);
ListView_SetItemState(hList,item, LVIS_SELECTED ,LVIS_SELECTED);
ListView_SetItemState(hList,item, LVIS_FOCUSED ,LVIS_FOCUSED);
 
Probably you have seen that: http://www.codeproject.com/KB/combobox/listview.aspx
 
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now