Solved

How get a checked/unchecked message from CTreeCtrl?

Posted on 2004-03-25
6
801 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 50 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
Independent Software Vendors: 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!

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

726 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