CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: controls

  1. #1
    Join Date
    Mar 1999
    Posts
    1

    controls



    I have just written a program that uses Tree views (controls).


    What I want to do is to be able to launch a dialog box once the user clicks on any of the items in the Tree view. How can I do this.


    Thank you very much.

  2. #2
    Join Date
    Apr 1999
    Posts
    191

    Re: controls



    Fortunately, this is one of the easy ones. Create your dialog box with the resource editor. Add a handler to your tree control using the class wizard. Then in that handler, declare your dialog and run it:


    CMyTreeView::OnLClick(...)

    {

    CMyDialog dlg;


    if(dlg.DoModal() == IDOK)

    ...

    }

  3. #3
    Join Date
    Apr 1999
    Posts
    20

    Re: controls



    To further elaborate on Bore's answer...


    Create a handler for the LButtonDown event as he mentions, and in that handler what you will want to do is use the point that is passed to you and pass it to CTreeCtrl::HitTest(). This function will tell you if the point where the mouse was clicked is actually ON an item in the tree or not, which I believe is what you really want. If you don't use the hit test, your handler will work no matter where the user clicks within the tree (in other words, NOT on an item).

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