Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

popup menu on a treeview

Posted on 1999-08-02
7
Medium Priority
?
756 Views
Last Modified: 2010-04-04
when a right mouse button ressed on the treeview, it highlights the corresponding item, but when it is released and popup menu pops up, the highlight "jumps" back to the previous item selected. the "RightClickSelect" property doesn't work properly either(which I was notified by help, after I saw this "live" :-E ). I tried to simulate click and then pop up the menu, but didn't have success. how to make it work properly?
0
Comment
Question by:duke_n
[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
7 Comments
 
LVL 2

Expert Comment

by:CalvinDay
ID: 1392473
In your click event, try this:

 for i:=0 to Tree.Items.Count-1 do
   if Tree.Items[i].Focused then
     Tree.Items[i].Selected:=True;

0
 
LVL 1

Author Comment

by:duke_n
ID: 1392474
nope, muchacho :-(.
the highlight jumps back away
0
 
LVL 6

Expert Comment

by:edey
ID: 1392475
What if you don't assing a popup, but catch thw WM_NCHITTEST message and call the popup from there?  This might also give you anothr op. to manually select the correct item.  Anyone with vcl source know why this happens?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 10

Accepted Solution

by:
viktornet earned 120 total points
ID: 1392476
Here is how this is done!!

procedure TForm1.FormCreate(Sender: TObject);
begin
     TreeView1.RightClickSelect := True;
end;

procedure TForm1.TreeView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
     if Button = mbRight then TreeView1.Selected.Selected := True;
end;

..-=ViKtOr=-..
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1392477
hi duke_n,

more easy is to do this (a curiuos way ;-)) is to assign the onpopup-event of your popupmenu to this procedure

procedure TForm1.PopupMenu1Popup(Sender: TObject);
begin
  Treeview1.Selected := Treeview1.Selected;  //it works
end;

meikl
0
 
LVL 1

Author Comment

by:duke_n
ID: 1392478
That works good.
//to meikl
my, that's weird. but Vitya here posted his answer first
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1392479
haha... Vitya is in Russian but I don't like that name as much ;)))
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

705 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