Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How get a checked/unchecked message from CTreeCtrl?

Posted on 2004-03-25
6
Medium Priority
?
810 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
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

604 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