Solved

Scroll in TreeView components

Posted on 2003-10-30
4
482 Views
Last Modified: 2010-04-05
I have a TreeView (in a Delphi 7 program) and one of the operations I want supported is to "Move" elements between nodes. The problem is that when I'm dragging an element and the target node is out of sight the view does not scroll down to show the other elements.

How can I add scroll up and down when the cursor gets out of the control's boundaries ?

Thanks in advance !


AJ
0
Comment
Question by:ajgonzalezm
[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
4 Comments
 
LVL 5

Accepted Solution

by:
snehanshu earned 50 total points
ID: 9654776
Does this help?
(Changing Drag-Over event of the TreeView);

procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
   // draggin over
  if (Sender is TForm) and (Source is TTreeView) then
    begin
    with Source as TTreeView do
        // check if we are in the hot zone (in this case only above or below)
      if (x > Left) and (x < Left + Width) and
         (y > Top - HOTZONE_WIDTH) and (y < Top + Height + HOTZONE_WIDTH)
        then begin
          Accept := true;  // we could set false here, too.
          if y < Top
            then Perform(WM_VSCROLL, SB_LINEUP, 0)
            else Perform(WM_VSCROLL, SB_LINEDOWN, 0);
          end
        else Accept := false;
    end
  else
    Accept := (Sender = Source);
end;

I picked this up from
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10125137.html?query=TreeView+Scroll&searchType=topic

HTH,
...Snehanshu
0
 
LVL 27

Assisted Solution

by:kretzschmar
kretzschmar earned 50 total points
ID: 9677227
well, another method

procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
var ANode : TTreeNode;
begin
  ANode := TreeView1.GetNodeAt(x,y);
  Accept := assigned(ANode); //just as sample
  //Scrolling needed ?
  if ((y < 9) or
     (y > TreeView1.Height - 9)) and
     (assigned(ANode)) then
    //ScrollUp ?
    if (y < 5) then
      ANode := ANode.getPrevSibling
    else
      ANode := ANode.getNextSibling;
  If assigned(ANode) then
    ANode.MakeVisible;
end;

meikl ;-)
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month5 days, 17 hours left to enroll

627 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