Solved

Scroll in TreeView components

Posted on 2003-10-30
4
481 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
error 1.1 400 Bad request idhttp delphi 18 280
Delphi selector screen 2 97
Delphi Firemonkey Need Sample for Online Shopping Example. 2 218
RESTRequest Parameter 4 83
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

751 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