Link to home
Start Free TrialLog in
Avatar of keithcsl
keithcsl

asked on

Scrolling...

Hi

i have got a treeview and nodes that i can add to it. how do i find out if the scroll bars have been activated (visible), ie when there are nodes out of the client area? is it possible to find out specifically if it is the vertical or horizontal bar that is activated?

also, if that is achievable, how do i find out the current position of either of the scroll bars?

Reagard
Keith
ASKER CERTIFIED SOLUTION
Avatar of viktornet
viktornet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
here is some more code...

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;

procedure TForm1.TreeView1EndDrag(Sender, Target: TObject; X, Y: Integer);
begin
  Timer1.enabled := false;
end;

procedure TForm1.TreeView1StartDrag(Sender: TObject;
  var DragObject: TDragObject);
begin
  // starting drag
  Timer1.enabled := true;
end;

end.
Avatar of keithcsl
keithcsl

ASKER

Viktornet,

hei, incidently, i am trying to do the same function as your code. several comments:

1. i still get double imaging when i drag a node

to stop the double imaging, i use treeview.refresh, but this wipes out the mouse cursor as well. do u know how to refresh the cursor?? i have tried almost everything, but still cannot get the cursor to appear after a refresh!

2. if TreeView.Height < TreeView.Items.Count * 16 then will not work if some parts of the tree is not expanded

Additional comment:
the scrolling process is also quite fast, but i solved this using delays and custom messages (i can post my code if u r interested)

Regards
Keith

yeah you can send your code,...

here are few scoll bars functions.... use GetScrollPos() to get the position of the scrolling bar...

EnableScrollBar
GetScrollPos
GetScrollInfo
GetScrollRange
ScrollDC
ScrollWindow
ScrollWindowEx
SetScrollInfo
SetScrollPos
SetScrollRange
ShowScrollBar

about the cursor i have no idea... maybe they forgot to update it in the dragging process.. it would be good if you let me see your code...

Hope this helps...

-Viktor-
i stuffed my coding viktor. it's because i am trying to dealy the scrolling, it does not refresh properly... the problem only happens if i have got images loaded for the nodes. refresh will only work if it is placed in the OnDragOver procedure..

so, i have solved the dragging problem, but still cannot determind if the scroll bar exists and whether the position is already at the min/max (then i don't have to scroll)...

Regards
ketih
Check out the Win32 help file and go under TreeViews and look u[p the info on it... You'll find everything you need there....

-Viktor-
viktornet

thank u for all ur help. i am using the Perform() function instead of the SendMessage()...

PS: i am still experimenting with determining the existence of the scroll bars

Regards
Keith