6
나는 2Treeviews입니다. 둘 다 같은 수의 항목을 가지고 있습니다. 나는 동기화 할 수 있도록하고 싶습니다 자신의 스크롤바를 ... 나는 그들 중 하나, 또 다른 이동 ... 수평 들어2Treeviews의 스크롤을 동기화하는 방법은 무엇입니까?
를 이동하는 경우, 그것은 작동 내가 ... 을 예상대로 수직, 나는이 스크롤 바의 화살표를 사용하는 경우 그것은 작동하지만, 나는 엄지 손가락을 끌어 하지 않는 경우 또는 내가 마우스 휠를 ... 사용하는 경우 여기
내가했습니다 샘플입니다 내 문제를 설명하기 위해 작성 :unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StrUtils;
type
TForm1 = class(TForm)
tv1: TTreeView;
tv2: TTreeView;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
originalTv1WindowProc : TWndMethod;
originalTv2WindowProc : TWndMethod;
procedure Tv1WindowProc (var Msg : TMessage);
procedure Tv2WindowProc (var Msg : TMessage);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
for i := 0 to 10 do
begin
tv1.Items.AddChild(nil, DupeString('A', 20) + IntToStr(i));
tv2.Items.AddChild(nil, DupeString('B', 20) + IntToStr(i));
end;
originalTv1WindowProc := tv1.WindowProc;
tv1.WindowProc := Tv1WindowProc;
originalTv2WindowProc := tv2.WindowProc;
tv2.WindowProc := Tv2WindowProc;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
tv1.WindowProc := originalTv1WindowProc;
tv2.WindowProc := originalTv2WindowProc;
originalTv1WindowProc := nil;
originalTv2WindowProc := nil;
end;
procedure TForm1.Tv1WindowProc(var Msg: TMessage);
begin
originalTv1WindowProc(Msg);
if ((Msg.Msg = WM_VSCROLL)
or (Msg.Msg = WM_HSCROLL)
or (Msg.msg = WM_Mousewheel)) then
begin
// tv2.Perform(Msg.Msg, Msg.wparam, Msg.lparam);
originalTv2WindowProc(Msg);
end;
end;
procedure TForm1.Tv2WindowProc(var Msg: TMessage);
begin
originalTv2WindowProc(Msg);
if ((Msg.Msg = WM_VSCROLL)
or (Msg.Msg = WM_HSCROLL)
or (Msg.msg = WM_Mousewheel)) then
begin
// tv1.Perform(Msg.Msg, Msg.wparam, Msg.lparam);
originalTv1WindowProc(Msg);
end;
end;
end.
DFM :
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 113
ClientWidth = 274
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 13
object tv1: TTreeView
Left = 8
Top = 8
Width = 121
Height = 97
Indent = 19
TabOrder = 0
end
object tv2: TTreeView
Left = 144
Top = 8
Width = 121
Height = 97
Indent = 19
TabOrder = 1
end
end
나는 또한 TTreeView는에서 서브 클래스를 만드는 시도했지만 성공 (같은 동작)없이 ... 나는 잇는 TMemo와 노력, 그리고 기대 작품으로 ...
무엇을 놓쳤습니까?
건배,
W.