Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I got a partial, but now full working solution (at least for two TMemo)...</p> <p>I mean partial, because it only listen for changes on one TMemo but not on the other... </p> <p>I mean full working because it does not depend on what is done... </p> <p>It is just as simple as put same horizontal scroll value on one Memo as it is on the other...</p> <p>It is nothing related with messages, but since i was trying to get a working solution by trapping messages WM_HSCROLL, etc... i left the code because it works ... i will try to improve it later... for example trapping only WM_PAINT, or in other ways... but for now, i put it as i have it since as that it works... and i did not find anywhere something yet better...</p> <p>Here is the code that works:</p> <pre><code>// On private section of TForm1 Memo_OldWndProc:TWndMethod; // Just to save and call original handler procedure Memo_NewWndProc(var TheMessage:TMessage); // New handler // On implementation section of TForm1 procedure TForm1.FormCreate(Sender: TObject); begin Memo_OldWndProc:=Memo1.WindowProc; // Save the handler Memo1.WindowProc:=Memo_NewWndProc; // Put the new handler, so we can do extra things end; procedure TForm1.Memo_NewWndProc(var TheMessage:TMessage); begin Memo_OldWndProc(TheMessage); // Let the scrollbar to move to final position Memo2.Perform(WM_HSCROLL ,SB_THUMBPOSITION+65536*GetScrollPos(Memo1.Handle,SB_HORZ) ,0 ); // Put the horizontal scroll of Memo2 at same position as Memo1 end; procedure TForm1.FormDestroy(Sender: TObject); begin Memo1.WindowProc:=Memo_OldWndProc; // Restore the old handler end; </code></pre> <p>It works for all ways to make scroll to change... </p> <p>Notes:</p> <ul> <li>I know it is horrible to trap all messages, but at least works...</li> <li>this is my first successfull attempt to have two TMemos with synced horizontal scrollbar...</li> <li>So, if someone can improve it a little (not trap all messages) please do it and post it.</li> <li>It only makes Memo1 to be on horizontal sync with Memo2 bar, but not Memo2 to be on sync with Memo1</li> <li>Press keys up, down, left, right, mousewheel, etc... whatever you want but on Memo2 to see it in action</li> </ul> <p>I will try to improve it by: when doing something on Memo2, Memo1 scroll still be on sync...</p> <p>I think it can work for allmost any control that has a ScrollBar, not only TMemo...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload