CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2001
    Posts
    251

    Ctreectrl problem

    I have an odd problem involving Ctreectrl. When I add the TVS_DISABLEDRAGDROP flag to my
    Ctreectrl creation, OnLButtonUp gets called as expected. But, when I remove it,
    OnLButtonUp doesn't get called anymore.

    More specifically, OnLButtonUp works, but only after a drag and drop operation.
    It no longer works for checked boxes.

    Is there some buried MFC function that steals it, when drag and drop is enabled?
    How do I get it back for checked boxes?
    Last edited by Syslock; December 14th, 2010 at 11:43 PM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Ctreectrl problem

    1. Where and why do you need OnLButtonUp functionality?
    2. Have a look at this thread.
    Victor Nijegorodov

  3. #3
    Join Date
    Nov 2001
    Posts
    251

    Re: Ctreectrl problem

    edited:
    My Ctreectrl has imagelist icons that look like checkboxes, but it doesn't use the TVS_CHECKBOXES flag.
    It gets checked when OnLButtonUp is called.

    But, this functionality is broken when drag and drop is enabled. The call to OnLButtonUp goes missing,
    and MFC is apparently to blame.
    Last edited by Syslock; December 15th, 2010 at 09:23 AM.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Ctreectrl problem

    And what does the TVS_HASBUTTONS style have to do with checkboxes?
    Has buttons
    Displays plus (+) and minus (-) buttons next to parent items. The user clicks the buttons to expand or collapse a parent item’s list of child items. To include buttons with items at the root of the tree view, Lines at root must be set to true. Type: Bool. Default: False.
    Victor Nijegorodov

  5. #5
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: Ctreectrl problem

    Quote Originally Posted by Syslock View Post
    My Ctreectrl has buttons that look like checkboxes, but it doesn't use the TVS_CHECKBOXES flag.
    It uses the TVS_HASBUTTONS flag. It gets checked when OnLButtonUp is called.

    But, this functionality is broken when drag and drop is enabled. The call to OnLButtonUp goes missing,
    and MFC is apparently to blame.
    It is a wrong approach if you handle buttons within the tree control by handling mouse messages. Instead you should handle notifications like NM_CLICK of the tree control. Or the buttons placed on the tree control could be separate controls which have their own handlers, e. g. for BN_CLICKED.

  6. #6
    Join Date
    Nov 2001
    Posts
    251

    Re: Ctreectrl problem

    Thanks, but does a NM_CLICK simulate an "upclick" ?

    I want to place the checkmark at the upclick, not the downclick.

    I searched the wine source for a reason why the OnLButtonUp handler goes missing, but couldn't find it:
    http://source.winehq.org/source/dlls...l32/treeview.c

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Ctreectrl problem

    Quote Originally Posted by Syslock View Post
    I searched the wine source for a reason why the OnLButtonUp handler goes missing, but couldn't find it:
    http://source.winehq.org/source/dlls...l32/treeview.c
    But what does wine have to do with Microsoft MFC CTreeCtrl class?
    Victor Nijegorodov

  8. #8
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: Ctreectrl problem

    Quote Originally Posted by Syslock View Post
    Thanks, but does a NM_CLICK simulate an "upclick" ?

    I want to place the checkmark at the upclick, not the downclick.

    I searched the wine source for a reason why the OnLButtonUp handler goes missing, but couldn't find it:
    http://source.winehq.org/source/dlls...l32/treeview.c
    The WM_LBUTTONUP is missing cause there is no need for handling this message if no drag-drop operation is allowed. So the message probably was sent to the dialog and not to the tree control.

    The NM_CLICK was sent *after* the user clicked to a part of the tree control but not if there is a separate control window or button which has its own message handling. 'clicked' means the button was down and up. If you hold the button there is no click.

    I recommend against implementing a behavior that isn't standard. So an action caused by a button click should work immediately for the object that was clicked on, i. e. the object that was pointed to when the button was down.

  9. #9
    Join Date
    Nov 2001
    Posts
    251

    Re: Ctreectrl problem

    But what does wine have to do with Microsoft MFC CTreeCtrl class?
    It's not the real source, but it's always very close. What I'm looking for is probably buried in the
    base class somewhere.

    Thanks, I will try to use NM_CLICK.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured