Solved

Sending CListCtrl's NM_CLICK to parent

Posted on 1997-08-05
5
1,077 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:jli
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:mbhakta
ID: 1303131
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 ?
0
 

Accepted Solution

by:
zafir earned 50 total points
ID: 1303132
In COwnListCtrl::OnLButtonDown() call
DefWindowProc( WM_LBUTTONDOWN, nFlags, MAKELONG( 2, point.y ));

This will take care of the selection and also send the notification.

0
 

Author Comment

by:jli
ID: 1303133
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

0
 

Expert Comment

by:zafir
ID: 1303134
Why are you calling the base class version of OnLButtonDown() after already having called the DefWindowProc(). Remove call
to CListCtrl::OnLButtonDown().
0
 

Author Comment

by:jli
ID: 1303135
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().
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
repeatSeparator  java  challenge 13 58
Separate into files by filename 12 91
Separate files macro - Errors on larger data set 18 73
sumDigits challenge 9 172
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question