Einzelnen Beitrag anzeigen

Benutzerbild von Flocke
Flocke

Registriert seit: 9. Jun 2005
Ort: Unna
1.172 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#7

Re: 2 TEdits synchron scrollen

  Alt 14. Jun 2005, 22:47
Sollte so aussehen (ungetestet):
Delphi-Quellcode:
const
  // Braucht mindestens ein RichEdit 3.0!
  {$EXTERNALSYM EM_GETSCROLLPOS}
  EM_GETSCROLLPOS = WM_USER + 221;
  {$EXTERNALSYM EM_SETSCROLLPOS}
  EM_SETSCROLLPOS = WM_USER + 222;

procedure GetRichEditScrollPos(Rich: TCustomRichEdit; var Pnt: TPoint);
begin
  Rich.Perform(EM_GETSCROLLPOS, 0, Integer(@Pnt));
end;

procedure SetRichEditScrollPos(Rich: TCustomRichEdit; const Pnt: TPoint);
begin
  Rich.Perform(EM_SETSCROLLPOS, 0, Integer(@Pnt));
end;
Allerdings brauchst du für die Meldungen mindestens ein RichEdit in der Version 3.0.

Wenn du auch noch informiert werden willst, wann das Control gescrollt wird, dann musst du eine abgeleitete Klasse erstellen (das geht schon in allen 32-Bit-Versionen von RichEdit):
Delphi-Quellcode:
type
  TScrollRichEdit = class(TRichEdit)
  private
    FOnVerticalScroll: TNotifyEvent;
    FOnHorizontalScroll: TNotifyEvent;
  protected
    procedure CNNotify(var Message: TWMNotify); message CN_NOTIFY;
  published
    property OnVerticalScroll: TNotifyEvent read FOnVerticalScroll write FOnVerticalScroll;
    property OnHorizontalScroll: TNotifyEvent read FOnHorizontalScroll write FOnHorizontalScroll;
  end;

procedure TScrollRichEdit.CNNotify(var Message: TWMNotify);
begin
  case Message.NMHdr^.code of
    EN_VSCROLL:
      if Assigned(FOnVerticalScroll) then
        FOnVerticalScroll(Self);
    EN_HSCROLL:
      if Assigned(FOnHorizontalScroll) then
        FOnHorizontalScroll(Self);
    else
      inherited;
  end;
end;
Volker
  Mit Zitat antworten Zitat