Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2004

Tip: Looking for answers? Try searching our database.

Question about right click in a CTreeControl!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lars Gr?tteland - 06 May 2004 14:29 GMT
Hello!

Having problems about right clicking on an item in a tree control. The item
that is clicked on is not the right one.
If I have three items in a tree.
Here is my problem. I click on the first item with normal click. I click on
the third item with the right click mouse. In this event I had a messagebox
telling me which item is selected, and this one comes out with the first
item no mather what. I also tried to get into the OnSelchangedItemfieldtree
function - but with no luck.

How can I right click on the third one and get its name out of it? Does
anyone know?
Signature


- Lars

Thangaraj - 06 May 2004 17:08 GMT
I guess u r using GetSelectedItem() within NM_RCLICK handler. The default
behaviour of TreeCtrl does'nt select an item on getting RClick.

Try the following code, it worked for me

void CMyTreeCtrl::OnRclick(NMHDR* pNMHDR, LRESULT* pResult)
{
    CPoint pt;
    GetCursorPos(&pt);
    ScreenToClient(&pt);

    UINT flags;
    HTREEITEM hItem = HitTest( pt, &flags );
    if  ( hItem &&
           flags & TVHT_ONITEM )
    {
             MessageBox( GetItemText(hItem) );
    }

    *pResult = 0;
}

hth
Thangaraj A.L.

> Hello!
>
[quoted text clipped - 9 lines]
> How can I right click on the third one and get its name out of it? Does
> anyone know?
Lars Gr?tteland - 07 May 2004 08:47 GMT
WOW
Thanks very much!

Could I ask you another one. If I drag an item in the tree - I would like it
to change place with that one I drag it over? How do I do that?

- Lars

Signature

- Lars

> I guess u r using GetSelectedItem() within NM_RCLICK handler. The default
> behaviour of TreeCtrl does'nt select an item on getting RClick.
[quoted text clipped - 38 lines]
> > How can I right click on the third one and get its name out of it? Does
> > anyone know?
Neel Roy - 06 May 2004 19:09 GMT
if you are trying to display selected item in OnRButtonDown before anything
happens then previous one would be still selected... If you are doing that
then perhaps you should put the same msg box on OnRButtonUp..

> Hello!
>
[quoted text clipped - 9 lines]
> How can I right click on the third one and get its name out of it? Does
> anyone know?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.