Link to home
Start Free TrialLog in
Avatar of jli
jli

asked on

Sending CListCtrl's NM_CLICK to parent

I have created a COwnListCtrl class derived from CListCtrl.  I have implemented the behavior of selecting an item even though user did not click the first column in the CListCtrl.  The problem that I am running into is I am not able to send the left mouse button click NM_CLICK from the COwnListCtrl::OnLButtonDown() to the parent when an user clicks in column other than the first column.  The parent of the COwnListCtrl is a property page.  How do I send the NM_CLICK in the WM_NOTIFY to the property page?  In the property page, I have two COwnListCtrl controls each with a different ID.
Avatar of mbhakta
mbhakta

Why do you want to send NM_CLICK to the parent ? A CDialog based window doesnot know what NM_CLICK is ? Can you explain why you need it ?
ASKER CERTIFIED SOLUTION
Avatar of zafir
zafir

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jli

ASKER

I did try your suggestion and placed the DefWindowProc() in the OnLButtonDown().  However, I ran into a situation where the       ON_NOTIFY(NM_CLICK, IDC_STUDY_LIST, OnClickStudyList)
 was received in the parent code only after the second left button down on the same item.  Again this left button down click was clicked in column other than the first column.  Below contains the code indicating where I have placed the DefWindowProc().

void COwnListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
      // TODO: Add your message handler code here and/or call default
      point.x = 2;
      DefWindowProc( WM_LBUTTONUP, nFlags, MAKELONG( 2, point.y ));

      CListCtrl::OnLButtonDown(nFlags, point);
}//endof OnLButtonDown

Why are you calling the base class version of OnLButtonDown() after already having called the DefWindowProc(). Remove call
to CListCtrl::OnLButtonDown().
Avatar of jli

ASKER

Without having the CListCtrl::OnLButtonDown() I don't get  ON_NOTIFY(NM_CLICK, IDC_STUDY_LIST, OnClickStudyList) in the parent, and I don't see any selection in the list control.  When I click the left button down in the first column, both of the things that I mentioned above occurred as well.  The only notification I get in the parent is ON_NOTIFY(LVN_ITEMCHANGED, IDC_STUDY_LIST, OnItemchangedStudyList).  This was the reason why I placed the CListCtrl::OnLButtonDown() in COwnListCtrl::OnLButtonDown().