Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HiTest() and CListBox.

Status
Not open for further replies.

WilliamGS

Programmer
Jan 21, 2004
54
PE
Hi All. I have a CListBox inside a CDialog and I am catching 'CDialog::OnContextMenu()', before show the menu I need to know what item is in the cursor position when the user performs double click; like 'HiTest()' in CListCtrl. CListBox does not have 'HiTest()'.

I am using VC++ 6.00

Thanks in advance,

William GS
 
Well, since right click also selects an item (if item is under mouse pos), you can check the currently selected item in the OnContextMenu.

Here's a snippet from a Doc-View app, but you get the idea...
Code:
void CSomeView::OnContextMenu(CWnd* pWnd, CPoint point) 
{
  CListCtrl& ctrl = GetListCtrl();
  POSITION itemPos = ctrl.GetFirstSelectedItemPosition();
  if (itemPos)
  {
     int itemIndex = ctrl.GetNextSelectedItem(itemPos);
	 ...
  }
  ...
}

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
Oh, CListBox...sorry. How about the CListBox::ItemFromPoint method?

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top