473,856 Members | 1,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about right click in a CTreeControl!

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 OnSelchangedIte mfieldtree
function - but with no luck.

How can I right click on the third one and get its name out of it? Does
anyone know?
--
- Lars
Nov 17 '05 #1
3 1435
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::On Rclick(NMHDR* pNMHDR, LRESULT* pResult)
{
CPoint pt;
GetCursorPos(&p t);
ScreenToClient( &pt);

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

*pResult = 0;
}
hth
Thangaraj A.L.
"Lars Grøtteland" <lars@nospam> wrote in message
news:ex******** ********@TK2MSF TNGP09.phx.gbl. ..
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 OnSelchangedIte mfieldtree function - but with no luck.

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

Nov 17 '05 #2
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..

"Lars Grøtteland" <lars@nospam> wrote in message
news:ex******** ********@TK2MSF TNGP09.phx.gbl. ..
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 OnSelchangedIte mfieldtree function - but with no luck.

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

Nov 17 '05 #3
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
--
- Lars
"Thangaraj" <th************ ************@re diffmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
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::On Rclick(NMHDR* pNMHDR, LRESULT* pResult)
{
CPoint pt;
GetCursorPos(&p t);
ScreenToClient( &pt);

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

*pResult = 0;
}
hth
Thangaraj A.L.
"Lars Grøtteland" <lars@nospam> wrote in message
news:ex******** ********@TK2MSF TNGP09.phx.gbl. ..
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

OnSelchangedIte mfieldtree
function - but with no luck.

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


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
309
by: William Bradley | last post by:
I have a production table and its accompanying form. There can be up to ten ingredients in what is produced. The ingredients are obtained from the incoming goods table which supplies the two parameters that I use, "Name" and "CatlogNo". This production table needs to contain each ingredient by name and catalogue number. With help from this list I was able to set up a combo box that allowed me to select a particular ingredient, and when...
7
2108
by: Michael C | last post by:
Hi all, I half-resolved my previous TreeView issue. Now I was wondering if anyone knows of a way to keep a TreeNode from being highlighted when it is left-clicked? It seems like there should be an event I could intercept, or a property I could set, but I'll be darned if I can figure out which one... Thanks, Michael C., MCDBA
1
1109
by: Lars Grøtteland | last post by:
Hello! If I select an item in a tree - and disable the whole tree - all the items in that tree is "grayed". How can I avoid that? This is how I would like things to work - only one item should be grayed - and I should not be able to click on this tree.
4
4421
by: I_AM_DON_AND_YOU? | last post by:
There is one more problem I am facing but didn't get the solution. In my Setup Program I am not been able to create 2 things (when the program is intalled on the client machine ) : (1) create shortcut to my program/utility (2) Entry in Windows' Start --> Program Menu. Actually in my VB.Net solution I have two projects (1) MYPROGRAM (2) MYPROGRAM_INSTALLER. MYPROGRAM is a "Windows Application". MYPROGRAM_INSTALLER is a "SetUp Wizard"...
7
1603
by: rforman1 | last post by:
Suppose I do this: let's say that in my vb.net app's main/MDI form, I declare a form-level variable of type Form1, where Form1 is another form (more technically, I know, another class which itself is inherited from system.windows.forms.form) defined in my application. dim mfrmForm1 as Form1 Okay, now let's also say I put two menu items on my MDI form, and code them something like this
6
4457
by: RG | last post by:
Hello – I’m relatively new to VB and I’m not getting how to do Dispose correctly from my readings. I have an application with 3 Forms (with a lot of logic going on within each): Form1, Form2, and a 3rd Form which is a dialog. - Form 1 at the top has: Dim frmTwo As New Form2
11
1462
by: A.M-SG | last post by:
Hi, I understand that be default VS2005 uses the ASP.NET development server to run and test ASP.NET applications. Is it possible that we use IIS for ASP.NET application debugging in new IDE environment?
2
2395
by: Crimson* | last post by:
I've got a table with an entry type as "OLE Object" in Access 2003. In the form that the table is linked to I want to insert an image (BMP) for each record. However, when I attempt to do so the file is inserted and the filename (image.bmp) is inserted in the box with it taking up about half of the box. I didn't have this problem in Access XP. I've tried embedding and linking the file, but this always happens. Can anyone offer any...
8
1622
by: Louis | last post by:
I was trying to display a custom context menu in javascript. I wanted to capture a right mouse click. I added an eventListener to a "div" like this.. element,addEventListener ("click", myfunc, true); When I tried to debug it, it seems to react fine to a left mouse click, but it totally ignores the right mouse click.
0
9762
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11057
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10696
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10384
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9531
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7094
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5761
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4575
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3201
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.