|
-
April 14th, 2004, 02:48 AM
#1
How can I get text of ListCtrl in another window when I put mouse on the list?
Hi all,
I want to get text of ListCtrl in another window when I put mouse on the ListCtrl.
I got CListCtrl* but I can't get text of specified (row, col).
//
CListCtrl* pListCtrl = (CListCtrl*)WindowFromPoint(ScreenPoint);
//
LVITEM lvi;
lvi.iItem = 0;
lvi.iSubItem = 3;
lvi.pszText = szBuffer;
lvi.cchTextMax = 255;
pListCtrl->GetItem(&lvi);
//
Here, the szBuffer is empty.
Please help me.
Thanks in advance,
Kim, YoungHwan.
-
April 14th, 2004, 03:21 AM
#2
Add this line before calling GetItem:
Code:
lvi.mask = LVIF_TEXT;
-
April 14th, 2004, 03:48 AM
#3
Originally posted by VictorN
Add this line before calling GetItem:
Code:
lvi.mask = LVIF_TEXT;
I did it, but the result was same.
-
April 14th, 2004, 04:08 AM
#4
I want to get text of ListCtrl in another window when I put mouse on the ListCtrl.
Is this "another window" in the same application or in some other?
If in the same - it should work. Anyway, try to use CListCtrl::GetItemText method and look at the return value. (BTW, have you allocated the buffer for szBuffer?)
If in the other - IMHO, it is impossible.
-
April 14th, 2004, 04:17 AM
#5
originally posted by VictorN
If in the other - IMHO, it is impossible.
its not impossible if its in another process there are ways for that.
-
April 14th, 2004, 04:26 AM
#6
Hi, siawos !
its not impossible if its in another process there are ways for that.
...using CListCtrl::GetItemText / CListCtrl::GetItem methods ?
-
April 14th, 2004, 04:40 AM
#7
originally posted by VictorN
using CListCtrl::GetItemText / CListCtrl::GetItem methods ?
yes with these calls or the calls behind these calls, i mean the messages that are sent behind these calls.
the only thing u need to cater are the process boundries for which there are several ways.
-
April 14th, 2004, 09:07 AM
#8
Originally posted by siawos
yes with these calls or the calls behind these calls, i mean the messages that are sent behind these calls.
the only thing u need to cater are the process boundries for which there are several ways.
Hi siawos,
I had tried sending a message to get text, but it was failed.
SendMessage() didn't work.
-
April 14th, 2004, 09:11 AM
#9
Originally posted by VictorN
Is this "another window" in the same application or in some other?
If in the same - it should work.  Anyway, try to use CListCtrl::GetItemText method and look at the return value. (BTW, have you allocated the buffer for szBuffer?)
If in the other - IMHO, it is impossible.
I meant it is of different application.
By the way, I can get selected item count but can't for texts.
Is there any differences between them?
-
April 14th, 2004, 10:45 AM
#10
if it is a different app, you need to hook into that.
There are ways to do it.
The reason why it works for count is the count is the return value of SendMessage(LVM_GETITEMCOUNT).
However, for getting the text, you pass a buffer, which is not a valid address in another process space ( exception being WM_GETTEXT across processes, which is handled differently ).
This article would probaly help
Last edited by kirants; April 14th, 2004 at 10:52 AM.
-
April 14th, 2004, 11:25 AM
#11
Originally posted by kirants
if it is a different app, you need to hook into that.
There are ways to do it.
The reason why it works for count is the count is the return value of SendMessage(LVM_GETITEMCOUNT).
However, for getting the text, you pass a buffer, which is not a valid address in another process space ( exception being WM_GETTEXT across processes, which is handled differently ).
This article would probaly help
I appreciate your reply very much, and I understand your explanations. BTW here, let me ask one more.
I could get edit controls' text of another process's window with sendmessage(WM_GETTEXT). Is this different form ListCtrl?
Thanks.
-
April 14th, 2004, 11:32 AM
#12
Originally posted by yhkim47
I could get edit controls' text of another process's window with sendmessage(WM_GETTEXT). Is this different form ListCtrl?
Yes. And I guess I did mention that as an exception.
-
April 14th, 2004, 12:30 PM
#13
Originally posted by kirants
Yes. And I guess I did mention that as an exception.
Oops, sorry I missed it.
Thanks anyway, and I'll read the article you suggested.
Thanks again.
-
April 15th, 2004, 12:51 AM
#14
posted by yhkim47
I could get edit controls' text of another process's window with sendmessage(WM_GETTEXT).
using sendmessage across process can cause blocking, for that u can either use PostMessage() or sendmessageTimeOut(), they dont cause blocking, and of these two SendMessageTimeOut() is a better option as long as the messages are not related to keyboard or mouse because they are normally posted.
theres another way besides those "three ways" check this article as well
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|