richedit1 과 richedit2를 한 form에 놓고
한쪽 richedit에서 스크롤을 움직일경우 다른 richedit에서도 똑같이 스크롤이
움직이도록 할려면 어떻게해야하나요...
묻고 답하기 모두 뒤져봐도 해답이 나오질 않습니다....ㅠㅠ
고수님들 답변부탁드립니다.
procedure TForm2.Re1WndProc(var Message: TMessage);
begin
if (Message.Msg = WM_HSCROLL) or (Message.Msg = WM_VSCROLL) then
begin
if (Message.Result <> RichEdit1.Handle) then
begin
Message.Result := RichEdit2.Handle;
Re2WndProc(Message);
end;
end;
SaveWndProc1(Message);
end;
procedure TForm2.Re2WndProc(var Message: TMessage);
begin
if (Message.Msg = WM_HSCROLL) or (Message.Msg = WM_VSCROLL) then
begin
if (Message.Result <> RichEdit2.Handle) then
begin
Message.Result := RichEdit1.Handle;
Re1WndProc(Message);
end;
end;
뭐 여러가지 방법이 있겠지만....
걍 Window Procedure를 바꾸어 버리세요....
type
TForm2 = class(TForm)
RichEdit1: TRichEdit;
RichEdit2: TRichEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
SaveWndProc1: TWndMethod;
SaveWndProc2: TWndMethod;
procedure Re1WndProc(var Message: TMessage);
procedure Re2WndProc(var Message: TMessage);
public
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
{ TForm2 }
procedure TForm2.FormCreate(Sender: TObject);
begin
SaveWndProc1 := RichEdit1.WindowProc;
SaveWndProc2 := RichEdit2.WindowProc;
RichEdit1.WindowProc := Re1WndProc;
RichEdit2.WindowProc := Re2WndProc;
end;
procedure TForm2.Re1WndProc(var Message: TMessage);
begin
if (Message.Msg = WM_HSCROLL) or (Message.Msg = WM_VSCROLL) then
begin
if (Message.Result <> RichEdit1.Handle) then
begin
Message.Result := RichEdit2.Handle;
Re2WndProc(Message);
end;
end;
SaveWndProc1(Message);
end;
procedure TForm2.Re2WndProc(var Message: TMessage);
begin
if (Message.Msg = WM_HSCROLL) or (Message.Msg = WM_VSCROLL) then
begin
if (Message.Result <> RichEdit2.Handle) then
begin
Message.Result := RichEdit1.Handle;
Re1WndProc(Message);
end;
end;
SaveWndProc2(Message);
end;
^^ 항상 즐코하세요...