?
Solved

How get a checked/unchecked message from CTreeCtrl?

Posted on 2004-03-25
6
Medium Priority
?
805 Views
Last Modified: 2013-11-20
How do I determine when the user is un/cheking a check box in a
 tree. What  notification message is sent?

0
Comment
Question by:robter_x
[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
6 Comments
 
LVL 16

Accepted Solution

by:
nonubik earned 150 total points
ID: 10686858
I presume you use a CTreeCtrl with TVS_CHECKBOXES.
I couldn't find any standard notification message, but I have an workarround: you may wait NM_CLICK and verify wether the checkbos is checked or not  (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/treeview/treeview.asp ,the last example in "Working with state image indexes") .
0
 
LVL 14

Expert Comment

by:_Stilgar_
ID: 14541570
I know it must be way too late now, but anyway, for the knowledgebase:
There is a better way - derive a class from CTreeCtrl and override with this one:

void CTreeCtrlEx::OnLButtonDown(UINT nFlags, CPoint point)
{
      UINT uFlags=0;
      HTREEITEM hItem = HitTest(point,&uFlags);

      if( uFlags & TVHT_ONITEMSTATEICON )
      {
            AfxMessageBox("Checked/unchecked");
            // determine by using GetCheck(hItem)
            // you can send a custom message if you want.
            return;
      }

      CTreeCtrl::OnLButtonDown(nFlags, point);
}

Stilgar.
0
 
LVL 1

Expert Comment

by:thready
ID: 21309279
Hi Stilgar,

I was just looking over these responses - it's been a long time, but maybe you can remember...  I subclassed CTreeCtrl and provided the virtual function to override OnLButtonDown as you said to do, but my function is not being called.  Do I absolutely need a message map so that it is called?  I'm not sure what to use as a message map if that's the case - how do you determine which dialog ID to use and still have a generic class?

Thanks for your help,
Mike
0
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 
LVL 14

Expert Comment

by:_Stilgar_
ID: 21316759
Hi,

Its been a while since I touched MFC GUI controls... AFAIR just overriding the function should do, but I may as well be wrong. Try creating the OnLButtonDown function in your sub-class using the MFC wizards - this should create whatever is needed for this function to work. Also, make sure you're not overriding this message elsewhere (for example in PreTranslateMessage).

Stilgar.
0
 
LVL 1

Expert Comment

by:thready
ID: 21318011
Thanks Stilgar, I'll give that a try..
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

752 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