Detecting column index of the item clicked
Posted
by Zafir Anjum
on August 6th, 1998
// HitTestEx - Determine the row index and column index for a point
// Returns - the row index or -1 if point is not over a row
// point - point to be tested.
// col - to hold the column index
int CMyListCtrl::HitTestEx(CPoint &point, int *col) const
{
int colnum = 0;
int row = HitTest( point, NULL );
if( col ) *col = 0;
// Make sure that the ListView is in LVS_REPORT
if( (GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT )
return row;
// Get the top and bottom row visible
row = GetTopIndex();
int bottom = row + GetCountPerPage();
if( bottom > GetItemCount() )
bottom = GetItemCount();
// Get the number of columns
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
// Loop through the visible rows
for( ;row <= bottom;row++)
{
// Get bounding rect of item and check whether point falls in it.
CRect rect;
GetItemRect( row, &rect, LVIR_BOUNDS );
if( rect.PtInRect(point) )
{
// Now find the column
for( colnum = 0; colnum < nColumnCount; colnum++ )
{
int colwidth = GetColumnWidth(colnum);
if( point.x >= rect.left
&& point.x <= (rect.left + colwidth ) )
{
if( col ) *col = colnum;
return row;
}
rect.left += colwidth;
}
}
}
return -1;
}
Date Last Updated: April 3, 1999

Comments
1 specific double turn on adidas
Posted by Updatatweda on 05/05/2013 11:55pmJ [url=http://www.adidaskutuja.com/]ã¢ãã£ãã¹[/url] cgRvf DmjUxl AzhHew AmwO [url=http://www.adidaskutuja.com/adidas-originals-c-4.html]adidas originals[/url] anDtvXfr JnpFzfMnyK [url=http://www.adidaskutuja.com/adidas-superstar-c-2.html]ã¢ãã£ãã¹ ã¹ã¿ã³ã¹ãã¹[/url] pg NpfMuv [url=http://www.adidaskutuja.com/jeremy-scott-c-5.html]ã¢ãã£ãã¹ é販[/url]ZkgKtv TqjTiq
ReplyLightweight perceptive â Nike Let off TR Befit in jump 2013 3 series
Posted by Tufffruntee on 04/24/2013 07:22pmNike Free TR Suited 3 salient features is to purchase the brand-new design: Nike On the loose 5 soles improved bending Groove; new tractor pattern making training more focused when; lighter ballast, the permeability is stronger, and more trendy shoe designs not not exhort shoes [url=http://markwarren.org.uk/property-waet.cfm]air max 90 uk[/url] more serene wearing, barefoot training feel, but also more stylish appearance. Nike On the house TR Fitting 3 provides supreme lateral perseverance, you can have the legs in the lap boost during training. Strong vamp majuscule letters breathable mesh, lower soap up's consonant design can be [url=http://markwarren.org.uk/goodbuy.cfm]nike free[/url] seen through it. Lightweight, ragged, thin bubbles matter familiar at hand merest occasional seams, more amenable, advocate is stronger. Lack more mainstay, factor of a training vex, foam come in more parts of the shortage after flexibility, effervescence loose. Say stand-in tongue moisture wicking mock materials, flat on your feet, refrain from living feet dry and comfortable. Phylite [url=http://markwarren.org.uk/goodbuy.cfm]nike free run uk[/url] midsole offers lightweight surprise sustained, outstanding durability and stable outsole can do to greatly adjust the total avoirdupois of the shoe. Qianzhang pods on the outsole and heel-shaped Unripened rubber enhances the shoe multi-directional purchase on different surfaces.
ReplyInteresting
Posted by snareenactina on 01/03/2013 09:15amusyet A study by the Federal Reserve Bank of Chicago published recently found little evidence to support the argument of a skills shortage driving up unemployment. Sharonsjââ¬âyour claim may be a more humanist, liberal point of view, but it is still an amusing conspiracy theory blaming Southern Republicans and big business for stealing from widows and orphans. Well, maybe you are half correct. If sj means Jesuit, I expected better. Secondly, that the regimeââ¬â¢s officially published inflation rate of 6.2 percent is fabricated. The real inflation rate is 16 percent, according to Lang. fundable Budget's van hire service can accommodate all of your needs to a very high standard. Whatever your payload and dimension requirements, no job is too big or small for our fleet. You may be looking to move house, or perhaps relocate a whole office, but whatever you need van hire for, we have the right vehicle for you at unbeatable prices. We have a large fleet of small, medium and large vans, you will find the vehicle that's right for you. redso God does not care about the nation, he cares about each and every one of you. I pray for your soul. copygrant Combined empezar That trade continued with few interruptions until 1638, when it was prohibited on the ground that the ships were smuggling priests into Japan. sccp Sort: daytona A large share of the leading statesââ¬â¢ institutions and residents have embraced the digital economy. Most of these states also have a solid innovation infrastructure that fosters and supports technological innovation, and many have a good quality of life coupled with high levels of domestic and foreign immigration of highly skilled knowledge workers. homicides Free subscriptions to our current and future global publications are available.
ReplyMissing licencing information
Posted by freds72 on 11/16/2010 11:48amWould it be possible to precise licencing terms for the related code source? Regards Frederic
ReplyMisses the last row
Posted by Mike Pliam on 04/28/2007 03:17amHas no one noticed that this technique misses the last visible row? How to fix that ?
Replyhelp me!
Posted by Legacy on 08/05/2002 12:00amOriginally posted by: hhh
where can i get the point parameter piont in function HitTestEx(CPoint &point, int *col) const from?
Replywhen the mouse point on the ListCtrl,how can i get the point? help me ?tanks a lot!
Also can use SubItemHitTest
Posted by Legacy on 05/31/2000 12:00amOriginally posted by: wen111
-
ReplyDoes not work
Posted by SteveS on 08/20/2004 03:31pmThis does not work for items in a listview unless the user happens to be over the first column of the list.
ReplyIf I don't use mouse
Posted by Legacy on 08/03/1999 12:00amOriginally posted by: Wen
If I use tab key and space bar to push the column
how can I detect the item number
-
-
Replyhow about selecting using ARROW KEYS?
Posted by Maverick5877 on 07/13/2005 05:53amMaybe you have an idea about getting the selected column index using arrow keys... i have problems on many ListCtrl events.. i.e. void ...OnLvnItemchangedListService(NMHDR *pNMHDR, LRESULT *pResult) { LPNMLISTVIEW pNMLV = reinterpret_cast(pNMHDR);
// pNMLV->subitem is always zero even if I have selected on
//columns other than the first one..
}
with OnNMClick().. subitem just works fine but
with all other event messages specially with the LVN_????() messages,
the subitem value of pNMHDR is not properly updated.. ReplyAnd if there is no click?
Posted by SteveS on 08/20/2004 03:33pmWhat if you're just hovering over the control and you don't click?
ReplyFix so that hit test works with reordered columns
Posted by Legacy on 07/05/1999 12:00amOriginally posted by: Andrew Skowronski
ReplyStack & Heap Based Singleton
Posted by Legacy on 05/17/1999 12:00amOriginally posted by: Thierry Bensoussan
The problem about Stack & Heap based singleton is discussed
in Pattern Hatching.
Although the use of a static member seems to be cleaner,
this solution is not usable in a multi-threaded environnement
where several threads can call the Instance() method
concurently.
In this context, the only right solution seems to be the one
using a static pointer to the Singleton with a "Destroyer"
inner class for memory management as described in
"Pattern Hatching".
However if you're not in a multi-threaded environnement, the
Replystatic instance solution seems right.
Loading, Please Wait ...