Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. problem selecting listview item

problem selecting listview item

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    method007
    wrote on last edited by
    #1

    I am using this code to select a listview item. i specify the postion of item using (WPARAM)2 . So this one supposed to highlight and selct the postion 2 in the listview. But unfortuently it does not select but it does deselct. I mean if the item is selected by mouse click it can deselect it but can not select it. Could any one tell me what i am doing wrong here.Thanks SendMessage(listview, LVM_SETITEMSTATE, (WPARAM)2, (LPARAM)_lvi); void CSelectuserDlg::OnButton1() { // TODO: Add your control notification handler code here HWND listview=NULL; // List View identifier HWND parent,child; parent=NULL; child=NULL; parent = ::FindWindow("My Window Class",NULL); child =::FindWindowEx(parent,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"WTL_SplitterWindow",NULL); child =::FindWindowEx(child,0,"ATL:0053C8D0",NULL); listview=::FindWindowEx(child,0,"SysListView32",NULL); LVITEM lvi, *_lvi; unsigned long pid; HANDLE process; GetWindowThreadProcessId(listview, &pid); process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, pid); _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM), MEM_COMMIT, PAGE_READWRITE); lvi.mask = LVIF_STATE; lvi.state = true; lvi.stateMask = LVIS_SELECTED; WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL); ::SendMessage(listview, LVM_SETITEMSTATE, (WPARAM)2, (LPARAM)_lvi); VirtualFreeEx(process, _lvi, 0, MEM_RELEASE); }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups