Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 7th, 2006, 04:06 PM
Friend of Wrox
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem selecting listview item

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 = ::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); 

 LVITEM lvi, *_lvi; 
 unsigned long pid; 
 HANDLE process; 

 GetWindowThreadProcessId(listview, &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);


Similar Threads
Thread Thread Starter Forum Replies Last Post
selecting a row in a listview control debbiecoates Pro VB Databases 0 February 26th, 2008 07:48 AM
How to get selected item from listview? try.test.abc C# 1 January 4th, 2007 02:34 AM
how to select an item from listview jthadathilm16 VB How-To 1 April 24th, 2006 11:33 AM
problem in selecting the item from drop down list swati_joshi ASP.NET 1.0 and 1.1 Basics 1 March 27th, 2006 01:24 AM
Selecting a ListView item bmains Pro VB.NET 2002/2003 0 January 22nd, 2005 11:19 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.