ListView_GetItemRect Help
I am new to Windows programming and I am trying to click an item in listview control for that I need to take the rect size of the listview.Can anyone help me regarding ListView_GetItemRect macro.
I used like this:
ListView_GetItemRect(e3Obj.eHwnd,3,&rec,LVIR_BOUNDS);
But I am not getting any values in the RECT rect.Kindly help me
Re: ListView_GetItemRect Help
- What value does this macro return? TRUE or FALSE?
- Is the e3Obj.eHwnd a correct control handle?
- Does an item with indesx 3 exist?
Besides, please, use Code tags and white spaces within the parameter list:
Code:
BOOL bRet = ListView_GetItemRect(e3Obj.eHwnd, 3, &rec, LVIR_BOUNDS);
Re: ListView_GetItemRect Help
1.Macro returns false
2.Yes eHwnd is the correct Handle as I checked with LVM_GETITEMCOUNT.
3.Yes there are total 20 items
b=ListView_GetItemRect(eHwnd, 3, &rec, LVIR_BOUNDS);
Can you please give me a small example how to use &rec. Thanks in advance
Re: ListView_GetItemRect Help
Quote:
Originally Posted by
haroonrulz
1.Macro returns false
It means that the call was unsuccessful.
Quote:
Originally Posted by
haroonrulz
Can you please give me a small example how to use &rec. Thanks in advance
Code:
Rect rect;
BOOL bRet = ListView_GetItemRect(e3Obj.eHwnd, 3, &rect, LVIR_BOUNDS);
Re: ListView_GetItemRect Help
The macro still returns FALSE.
1.Can you please let me know what would be the possible mistakes I would have done.
2.Is there any macro to click an item in listview or can you help/guide me regarding this.
Re: ListView_GetItemRect Help
1. There may be some reasons for ListView_GetItemRect to fail, like
- invalid window handle
- invalid item index
- perhaps, some others
2. What are you trying to achieve?
Re: ListView_GetItemRect Help
Sir I am developing an automation tool for which I need to click on the item in the listview. As there is no macro for directly clicking on listview item.One of my colleague suggested me, " to get the listview item size using ListView_GetItemRect and then try to convert it to X,Y mouse point and click on it".But I am completely blank. Please help me and sorry for disturbing you a lot sir.
Re: ListView_GetItemRect Help
Are you calling these LVM_GETITEMCOUNT, ListView_GetItemRect from the same process where list control is placed or in some other process?
Re: ListView_GetItemRect Help
I am calling in the same process.
Things I have done:
Sample code:
RECT rect;
int ix;
ix=ListView_GetItemCount(e3Obj.eHwnd);
//I am getting 20 in ix.Also I have checked it manually.
BOOL bRet = ListView_GetItemRect(e3Obj.eHwnd, 3, &rec, LVIR_BOUNDS);
Sir also let me know am I following the correct way to click on the item in listview or is there some other way.
Re: ListView_GetItemRect Help
Quote:
Originally Posted by
haroonrulz
I am calling in the same process.
Again: is it the same process that does contain this list control or is it some other process?
Quote:
Originally Posted by
haroonrulz
Sir also let me know am I following the correct way to click on the item in listview or is there some other way.
What do you mean by "click on the item in listview"? And what for?
What actions is this listview control supposed to do in response to your "click"?
1 Attachment(s)
Re: ListView_GetItemRect Help
Sir I am developing an automation tool.For that I need to click on list view item.Kindly look at the picture attached.Hope you understand my question.
Attachment 30821
Re: ListView_GetItemRect Help
Quote:
Originally Posted by
haroonrulz
Sir I am developing an automation tool.For that I need to click on list view item.Kindly look at the picture attached.Hope you understand my question.
No, I didn't.
Instead of repeating again and again about "automation" you should have better explained what you mean by this "automation" and answered on my questions:
Quote:
Originally Posted by
VictorN
Again: is it the same process that does contain this list control or is it some other process?
What do you mean by "click on the item in listview"? And what for?
What actions is this listview control supposed to do in response to your "click"?
Re: ListView_GetItemRect Help
If you are automating, then the &rec pointer may be valid in the context of YOUR program
but in the other program (WinSpy++) this address will not be valid.
Only SOME windows message calls will work when used on controls that have been created in another program/process.
Re: ListView_GetItemRect Help
Should I say it that I already warned you in the other thread? ;)
Quote:
Originally Posted by
haroonrulz
I am new to Windows programming and I am trying to click an item in listview control for that I need to take the rect size of the listview.Can anyone help me regarding ListView_GetItemRect macro.
Your problem is not the macro. Your problem is that you hardly understand how Windows controls work. You're looking for some magic macro while there is no one in your specific case.
Quote:
Originally Posted by
haroonrulz
Sir I am developing an automation tool for which I need to click on the item in the listview. As there is no macro for directly clicking on listview item.One of my colleague suggested me, " to get the listview item size using ListView_GetItemRect and then try to convert it to X,Y mouse point and click on it".But I am completely blank.
So you're not prepared enough for completing this task. You cannot develop anything complex in Windows being completely blank and new to Windows programming.
Now to your assignment.
It may be solved two different ways. First is code injection. This (writing code to remote process and creating remote thread) or that (injecting dll) way your code have to appear in the context of the process you to automate. Then by means of some IPC (inter-process communication) your code gets the command 'click on item 3', gets the corresponding item rect (by means of the macro, or sending LVM_GETITEMRECT, whatever), positions mouse cursor inside the rect, emulates left button down and button up events. I repeat: All this code is inside the victim process.
Second way implies no code injection, but ability to read/write the victim process memory is mandatory anyway. The automation process allocates remote memory enough to fit RECT in and passes the remote address to the macro, then it reads the rect coordinates and emulates the mouse button click as explained above. And does not forget to deallocate later, of course.
This is how it looks from "helicopter view". A special headache is acquiring rights enough to read/write remote process memory or inject dll, as since Vista times Microsoft decided to make this kind of tricks be much more tricky than it was before.
Now can anybody explain me how this could be done by somebody who's completely blank and new to Windows programming? Guys, if you really need some automation engine, you'd better go with already proved solutions like AutoIt
Re: ListView_GetItemRect Help
Dear Igor, Thanks for your advise/warning/solution .Surely It will help me a lot.