Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 7th, 2006, 04:06 PM
Friend of Wrox
Join Date: Mar 2005
Location: , , .
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);

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 11:14 PM.

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