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

x
?
Solved

SCROLL BY CLONE

Posted on 1999-07-20
11
Medium Priority
?
416 Views
Last Modified: 2010-04-04
I wish to hide a scollbar from a component ( tree , list , memo , DBGrid etc ) and to use a scrollbar located to another position .
For this I need to know all the time the max and position of , for example , TreeView to set my scrollbar . If I expand a node then my scrollbar will be change the max value and position , too .
For scroll I use Tree or else . Perform(WM_VSCROLL, SB_LINEDOWN, 0);  [(  SB_LINEDOWN, SB_LINEUP, SB_LINELEFT, SB_LINERIGHT)] .

In conclusion , I wish to hide the scrollbar of a component and to control this from a clone .

HOW CAN I HIDE THE SCROLLBAR FROM COMPONENT AND THEN TO USE AN ANOTHER SCROLLBAR ( ALIKE A CLONE OF THE FIRST ) TO CONTROL THE SCROLL OF COMPONENT .

Ginsonic

P.S. Please comment . If your comment help me I will notify you to put an answer .
0
Comment
Question by:ginsonic
[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
  • 6
  • 3
  • 2
11 Comments
 
LVL 10

Expert Comment

by:Lischke
ID: 1390101
Hi Ginsonic,

this will become difficult, but with a few tricks it should be possible. You can easily hide a window's scrollbar by setting its range to 0 (SetScrollInfo, note: at least the treeview is an exception, as there is a property to hide scroll bars, but you can still use SetScrollInfo).

Unfortunately, to know the max value and position of the scroll bar you had to query the the scroll info (which just set to 0). So this wouldn't help at all.

Here not the tricks I'd suggest. Usually you cannot hide a scroll bar without setting its range value to 0, but you can avoid that it is painted. Intercept the WM_NCPAINT message in the window and don't call the inherited method, but do all the drawing yourself. Since the scroll bar still has all its correct values, you can query them and paint your own scroll bar where you want.

Ciao, Mike
0
 
LVL 10

Expert Comment

by:Lischke
ID: 1390102
:-) Should read: Here now the trick...
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 300 total points
ID: 1390103
hi ginsonic,

an other trick,

to hide

  ShowScrollBar(TreeView1.Handle,SB_BOTH,False);

now the scrollbars are simple hidden, but you can use

GetScrollRange
GetScrollPos

to retrieve the information

to set you can use as u mationed above

sample with a treeview

unit scr_tree_u;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    TreeView1: TTreeView;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowScrollBar(TreeView1.Handle,SB_BOTH,False);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  TreeView1.Perform(WM_VSCROLL, SB_LINEDOWN,0);
  Label1.Caption := IntToStr(GetScrollPos(TreeView1.Handle,SB_VERT));
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  TreeView1.Perform(WM_VSCROLL, SB_LINEUP,0);
  Label1.Caption := IntToStr(GetScrollPos(TreeView1.Handle,SB_VERT));
end;

end.


meikl

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 10

Expert Comment

by:Lischke
ID: 1390104
Meikle, I wasn't sure out off my head about using ShowScrollBar (actually I didn't remember this call at the moment I wrote the comment).

But why did you propose an answer? Didn't you read the question entirly? BTW: You answered only the "hide scollbar" part, but what about the "cloning part"?

Ciao, Mike
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1390105
ok mike,

a bit cloning, just not perfect, but should shown how to do

unit scr_tree_u;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    TreeView1: TTreeView;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Label1: TLabel;
    ScrollBar1: TScrollBar;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure ScrollBar1Scroll(Sender: TObject; ScrollCode: TScrollCode;
      var ScrollPos: Integer);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var min,max : Integer;
begin
  ShowScrollBar(TreeView1.Handle,SB_BOTH,False);
  GetScrollRange(TreeView1.Handle,SB_VERT,Min,Max);
  Scrollbar1.Min := Min;
  Scrollbar1.Max := Max;
  ScrollBar1.Position := GetScrollPos(TreeView1.Handle,SB_VERT);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  TreeView1.Perform(WM_VSCROLL, SB_LINEDOWN,0);
  Label1.Caption := IntToStr(GetScrollPos(TreeView1.Handle,SB_VERT));
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  TreeView1.Perform(WM_VSCROLL, SB_LINEUP,0);
  Label1.Caption := IntToStr(GetScrollPos(TreeView1.Handle,SB_VERT));
end;

procedure TForm1.ScrollBar1Scroll(Sender: TObject; ScrollCode: TScrollCode;
  var ScrollPos: Integer);
begin
  Case ScrollCode of
    scLineUp : Button3.Click;
    scLineDown : Button2.Click;
    else ScrollBar1.Position := GetScrollPos(TreeView1.Handle,SB_VERT);
  end;
  Label2.Caption := IntToStr(ScrollBar1.Position);
end;

end.

meikl
0
 
LVL 10

Expert Comment

by:Lischke
ID: 1390106
Meikl, this should work well as long as Ginsonic accepts to have a standalone scroll bar which even can get the keyboard focus. But despite of this your code is a solution :-)

Ciao, Mike
0
 
LVL 9

Author Comment

by:ginsonic
ID: 1390107
Hi kretzschmar,
Your code report a value for range scroll bigger than maximum scroll position .
For example , in my case the range is 40 and the max position is 29 ( when I press the button for down ) .
ginsonic
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1390108
hi ginsonic,

as i said, just not perfect,
the range is returned from the api,
i think it depends on the dynamic thumb,
which is not available (?) by the ordinary scrollbar.

meikl
0
 
LVL 10

Expert Comment

by:Lischke
ID: 1390109
Meikl, the fixed thumb size of a scroll bar control is another limitation of it I didn't think of originally.

Nick, it is correct when the max position is smaller then the range. The range indicates the entire client height (or width, it depends on the scrollbar kind), while the maximum position is this height minus one client height as one usually can only scroll to the highest entry which ensures to be on top of the window while the rest of content fills exactly the client area.

Ciao, Mike
0
 
LVL 10

Expert Comment

by:Lischke
ID: 1390110
Sorry, there's again a wrong phrase slipped in... It should read: The range indicates the entire (virtual) height of a window (not only the client height)...

Ciao, Mike
0
 
LVL 9

Author Comment

by:ginsonic
ID: 1390111
I choice to use only buttons for scroll .
Thanks to all for help.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
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…
Suggested Courses

715 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