Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 7th, 2006, 05:03 PM
ehsanking ehsanking is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 207 ehsanking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 3 m 51 sec
Reputation Power: 4
Talking Problem selecting listview item in visual c++

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);
Code:
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_V  M_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);
	
}

Last edited by ehsanking : July 7th, 2006 at 05:08 PM.

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > Problem selecting listview item


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT