473,386 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to HitTest an item of a List Ctrl owned by another thread

I succeeded in obtaining a CListCtrl item info using HitTest() when the List
Ctrl is owned by my current thread. But when I tried HitTest an item of a
List Ctrl owned by other threads such as Explorer folder view, I failed. My
code is as follows:

// current cursor pos
CPoint pt;

// Suppose pWnd is the window owned by another thread
CListView* pListView = static_cast<CListView*>(pWnd);

// Get the reference of List Ctrl
CListCtrl& listCtrl = pListView->GetListCtrl();

if(listCtrl.GetItemCount() != 0)
{
::GetCursorPos(&pt);

// Get the client pos for HitTest
pListView->ScreenToClient(&pt);

LVHITTESTINFO lvhti;
lvhti.pt = pt;

// Now do HitTest() to get the item at current cursor pos
int nItem = listCtrl.HitTest(&lvhti);

if(nItem != -1)
{
...
}

...
}

The nItem always equals to -1 even if the mouse is on the list ctrl item,
which indicates that the HitTest() fails.

I also tried SubItemHitTest() and even AttachThreadInfo() but all seem not
work.

Can anyone help me solve the problem? Thanks.
Nov 17 '05 #1
0 1058

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: Gregor Horvath | last post by:
Hi, >>>type() <type 'list'> >>>type(('1')) <type 'str'> I wonder why ('1') is no tuple????
0
by: Stuart M. Ray | last post by:
Hi All, The first parameter on the System.Threading.Mutex constructor is a Boolean called initiallyOwned that, according to the documentation, will give the calling thread ownership if it is...
9
by: Max Weebler | last post by:
Hi, I have a datagrid built that has an alternating item style that sets the backcolor and ForeColor of its rows. I have 4 template columns. One of them has a LinkButton embedded in it to...
3
by: Maria Anthonsen | last post by:
I'm using HitTest to get a value from the cells into a textbox. I have put the HitTest code into the MouseDown-event, and everything is working except one thing. When I start the program the value...
2
by: Martin | last post by:
Hi all, I'm trying to correct the (imho) wrong behaviour of a listbox when the user right-clicks on an item. I would like the selection to change when this happens, just like when the user uses...
3
by: NaeiKinDus | last post by:
Hello, i'm trying to program a thread that would be locked (by a mutex) and that would only be unlocked once that a function (generating data) is done. The purpose is to generate data, and unlock...
5
by: Doug | last post by:
Hi I have a text box that can be used for input and I would like to check if the value in the text box that someone types is already in a list of items. I know how to do this in other languages...
11
by: Lamont Sanford | last post by:
Given an object of type Mutex, what method or property should be called to determine if it is currently owned? I could call WaitOne(0,false) -- and if the return value is false, I could deduce...
8
by: Ratko | last post by:
Say you have something like this: for item in myList: del item Would this actually delete the item from the list or just decrement the reference counter because the item in myList is not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.