如何同步两个TRichEdit的滚动条?

时间:2010-02-01 13:18:48  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读: PRichEdWndProc, POldWndProc: Pointer;    procedure RichEdWndProc(var Msg: TMessage);//...procedure TForm1.FormCreate(Sender: TObject);begin  PRichEdWndProc := MakeObjectInstance(RichEdWndProc);  POldWndProc    := Pointer(SetWindowLong(RichEdit1.H...
  正文:同步两个TRichEdit的滚动条:

/...
  private
    PRichEdWndProc, POldWndProc: Pointer;
    procedure RichEdWndProc(var Msg: TMessage);
//...


procedure TForm1.FormCreate(Sender: TObject);
begin
  PRichEdWndProc := MakeObjectInstance(RichEdWndProc);
  POldWndProc    := Pointer(SetWindowLong(RichEdit1.Handle, GWL_WNDPROC,
    Integer(PRichEdWndProc)));
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if Assigned(PRichEdWndProc) then
  begin
    SetWindowLong(RichEdit1.Handle, GWL_WNDPROC, Integer(POldWndProc));
    FreeObjectInstance(PRichEdWndProc);
  end;
end;


procedure TForm1.RichEdWndProc(var Msg: TMessage);
begin
  Msg.Result := CallWindowProc(POldWndProc, RichEdit1.Handle, Msg.Msg,
    Msg.wParam, Msg.lParam);

  if (Msg.Msg = WM_VSCROLL) and (LOword(Msg.wParam) = SB_THUMBTRACK) then
  begin
    Label1.Caption := 'Pos is ' + IntToStr(HIWORD(Msg.wParam));
    RichEdit2.Perform(Msg.Msg, Msg.wParam, Msg.lParam);
    SetScrollPos(RichEdit2.Handle, SB_VERT, HIWORD(Msg.wParam), True);
  end;
end;[/codde]

"如何同步两个TRichEdit的滚动条?"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Language/Delphi/12709.html


关键字:

关于《如何同步两个TRichEdit的滚动条?》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td