?
Solved

Sending CListCtrl's NM_CLICK to parent

Posted on 1997-08-05
5
Medium Priority
?
1,104 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 100 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

741 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