Autor Beitrag
r_le
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Mi 05.05.04 17:25 
Hi!

Ich habe hier 2 Scrollboxen (oder Scrollboxes? hmm...). Wenn ich die eine nun vertikal scrolle, dann soll gleichzeitig auch die andere gescrollt werden. Wie mach ich denn das? Hab leider bisher noch kein passendes Ereignis gefunden. :-(
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 06.05.04 15:08 
du kannst in eimem Timer die Postition der einen scrollbox anfragen und auf die andere übertragen:scrollbox1.HorzScrollBar.Position := scrollbox2.HorzScrollBar.Position;
genau das gelich halt auch mit der vertikalen scrollbar !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Benedikt
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 06.05.04 15:29 
Hi,

du könntest eine Klasse von TScrollBox ableiten welche ein OnScroll-Event published.

Hab sowas mal auf die Schnelle zusammengebastelt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
type
  TScrollNotifiyEvent=procedure(Sender: TObject; AVer, AHor: Integer) of object;

  TScrollBoxEx = class(TScrollBox)
  private
    FOnScroll: TScrollNotifiyEvent;
    procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
    procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
  published
    property OnScroll: TScrollNotifiyEvent read FOnScroll write FOnScroll;
  end;

implementation

procedure TScrollBoxEx.WMHScroll(var Message: TWMHScroll);
begin
        inherited;

        if (Assigned(FOnScroll)) then
                FOnScroll(Self, VertScrollBar.Position, HorzScrollBar.Position);
end;

procedure TScrollBoxEx.WMVScroll(var Message: TWMVScroll);
begin
        inherited;

        if (Assigned(FOnScroll)) then
                FOnScroll(Self, VertScrollBar.Position, HorzScrollBar.Position);
end;


Im neuen OnScroll-Event kannst du dann die Positionen beider Scrollboxen synchronisieren.
r_le Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Do 06.05.04 20:32 
Ja, das mit der neuen Klasse ist wahrscheinlich die einfachste Lösung.
Danke! :-)
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Fr 07.05.04 14:44 
jup das ist die eleganteste lösung. das mit dem timer wäre voll holzhammer gewesen !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
_janosch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Fr 07.05.04 15:39 
warum? Im Event onscroll bzw. onchange braucht doch einfach
ausblenden Delphi-Quelltext
1:
scrollbar2.Position:=scrollbar1.Position;					

bzw.
ausblenden Delphi-Quelltext
1:
scrollbar1.Position:=scrollbar2.Position;					

ausführen. Also ohne eine neue klasse oder ohne einen Timer!?
Benedikt
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 07.05.04 15:44 
_janosch hat folgendes geschrieben:
warum? Im Event onscroll bzw. onchange braucht doch einfach

Dann such diese Ereignisse mal bei der normalen TScrollbox... :wink: