CListCtrl::HitTest()
Calvin Tarlton -- Tarlton@iftech.com Tuesday, October 01, 1996 Environment: VC++ 4.2, NT 4.0 In my application, I use the CListCtrl::HitTest() to determine which item was clicked. Here's the code I use: const MSG* pMsg = GetCurrentMessage(); CPoint ptClicked = pMsg->pt; ScreenToClient( &ptClicked ); CPoint ptLabel = ptClicked; ptLabel.x = 0; int nItemLabel = m_pThisList->HitTest( ptLabel ); On NT 3.51 this code works fine, but on Windows 95 and NT 4.0, HitTest() always returns -1. Why? ---------------------------------------------------------------------- Calvin Tarlton tarlton@iftech.com Software Developer (919) 876-1566 x17 voice Interface Technologies, Inc. (919) 876-1779 fax Highwoods Office Center, 3120 Poplarwood Ct., Raleigh, NC 27604 Interface Technologies specializes in software design and programmer training on Windows NT and Windows 95 platforms For more information, visit http://www.iftech.com ----------------------------------------------------------------------
Roger Onslow/Newcastle/Computer Systems Australia/ Thursday, October 03, 1996 [Mini-digest: 3 responses] Try ptLabel.x = 1; // not 0 Roger Onslow -----From: "GoroKhM1"Environment: VC++ 4.2, NT 4.0 You wrote: > snip >On Windows 95 and NT 4.0, HitTest() always returns -1. That is working fine in my app in Win95 + VC 4.x: CPoint cpClick = ::GetMessagePos(); ScreenToClient(&cpClick); int iHitRow = m_pList->HitTest(cpClick); -Mark -----From: Calvin Tarlton Thanks to all that responded. I changed it to x=1 and that still didn't work. I then realized that other higher values of x did work. Anyway, it turns out that items in the list start at x=2. Go figure... [Moderator's note: You may recall that my personal reply to you suggested using 4 instead of 0 or 1. There was a recent discussion on getting the Edit control of a ComboBox that tipped me off.] Also, GetCurrentMessage()->pt seems to be the same as GetMessagePos(). ---------------------------------------------------------------------- Calvin Tarlton tarlton@iftech.com Software Developer (919) 876-1566 x17 voice Interface Technologies, Inc. (919) 876-1779 fax Highwoods Office Center, 3120 Poplarwood Ct., Raleigh, NC 27604 Interface Technologies specializes in software design and programmer training on Windows NT and Windows 95 platforms For more information, visit http://www.iftech.com ----------------------------------------------------------------------
| Вернуться в корень Архива |