![]() |
Memos synchron scrollen
Hy DP,
Ich möchte gerne zwei Memos synchron scrollen. Ich habe auch schon was gefunden: ![]() Nur ist hier jetzt das Problem: Wenn ich Memo1 scrolle, scrollt Memo2 auch. :-D Soweit so gut. Aber wenn ich Memo2 scrolle, scrollt Memo1 nicht. :cry: Meine Frage jetzt: Wie kann ich es auf beide anwenden. Ich hab auch schon den Code zu kopieren und auf Memo2 anwenden. Ergebnis: Negativ. Vllt habe ich auch etwas falsch gemcht. Ich wäre dankbar wenn ihr mir helfen könnt. :thumb: MFG Muellermilchtrinker (der mit den vielen Fragen :stupid: ) |
Re: Memos synchron scrollen
Zitat:
|
Re: Memos synchron scrollen
Das wär die ganze Unit:
Delphi-Quellcode:
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; Memo2: TMemo; procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private-Deklarationen } PRichEdWndProc, POldWndProc: Pointer; PRichEdWndProc2, POldWndProc2: Pointer; procedure RichEdWndProc(var Msg: TMessage); procedure RichEdWndProc2(var Msg: TMessage); public { Public-Deklarationen } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin PRichEdWndProc := MakeObjectInstance(RichEdWndProc); POldWndProc := Pointer(SetWindowLong(Memo1.Handle, GWL_WNDPROC, Integer(PRichEdWndProc))); PRichEdWndProc2 := MakeObjectInstance(RichEdWndProc); POldWndProc2 := Pointer(SetWindowLong(Memo2.Handle, GWL_WNDPROC, Integer(PRichEdWndProc2))); end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin if Assigned(PRichEdWndProc) then begin SetWindowLong(Memo1.Handle, GWL_WNDPROC, Integer(POldWndProc)); FreeObjectInstance(PRichEdWndProc); end; if Assigned(PRichEdWndProc2) then begin SetWindowLong(Memo2.Handle, GWL_WNDPROC, Integer(POldWndProc)); FreeObjectInstance(PRichEdWndProc2); end; end; procedure TForm1.RichEdWndProc(var Msg: TMessage); begin Msg.Result := CallWindowProc(POldWndProc, Memo1.Handle, Msg.Msg, Msg.wParam, Msg.lParam); if (Msg.Msg = WM_VSCROLL) and (LOWORD(Msg.wParam) = SB_THUMBTRACK) then begin Memo2.Perform(Msg.Msg, Msg.wParam, Msg.lParam); SetScrollPos(Memo2.Handle, SB_VERT, HIWORD(Msg.wParam), True); end; end; procedure TForm1.RichEdWndProc2(var Msg: TMessage); begin Msg.Result := CallWindowProc(POldWndProc, Memo2.Handle, Msg.Msg, Msg.wParam, Msg.lParam); if (Msg.Msg = WM_VSCROLL) and (LOWORD(Msg.wParam) = SB_THUMBTRACK) then begin Memo2.Perform(Msg.Msg, Msg.wParam, Msg.lParam); SetScrollPos(Memo1.Handle, SB_VERT, HIWORD(Msg.wParam), True); end; end; end. |
Re: Memos synchron scrollen
Was mir auf die Schnelle aufffällt:
In RichEdWndProc machst du ein Memo2.Perform und SetScrollPos(Memo2....) In RichEdWndProc2 machst du ein Memo2.Perform und SetScrollPos(Memo1....) Ich denke du müßtest in ichEdWndProc2 ein Memo1.Perform machen |
Re: Memos synchron scrollen
Danke. :thumb:
Warn zwar noch zwei/drei andere Kleinigkeiten, funktioniert aber jetzt. Kommt davon wenn man Copy&Paste nutzt :oops: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:01 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz