Uwe Raabe 2103 Posted Monday at 05:07 PM Perhaps you should specify the tests you are doing more precisely. Share this post Link to post
limelect 51 Posted Monday at 05:40 PM (edited) I do not know what to say see moving horizontally Obviously, something is fishy unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TLinkMemo = class(TMemo) private FLinkedMemo: TLinkMemo; procedure SyncLink; protected procedure WndProc(var Message: TMessage); override; public property LinkedMemo: TLinkMemo read FLinkedMemo write FLinkedMemo; end; TMemo = class(TLinkMemo); TForm1 = class(TForm) Memo1: TMemo; Memo2: TMemo; procedure FormCreate(Sender: TObject); private public end; var Form1: TForm1; implementation {$R *.dfm} procedure TLinkMemo.WndProc(var Message: TMessage); begin inherited; if (LinkedMemo = nil) or not LinkedMemo.HandleAllocated then Exit; case Message.Msg of WM_HSCROLL, WM_VSCROLL, WM_KEYDOWN, WM_MOUSEFIRST..WM_MOUSELAST: SyncLink; end; end; procedure TLinkMemo.SyncLink; procedure UpdateScrollBar(BarFlag: Integer; Msg: Cardinal); var scrollInfo: TScrollInfo; begin scrollInfo.cbSize := SizeOf(scrollInfo); scrollInfo.fMask := SIF_POS; if GetScrollInfo(Handle, BarFlag, scrollInfo) then LinkedMemo.Perform(Msg, MAKEWPARAM(SB_THUMBPOSITION, scrollInfo.nPos), 0); end; var savedLink: TLinkMemo; begin savedLink := LinkedMemo.LinkedMemo; try LinkedMemo.LinkedMemo := nil; UpdateScrollBar(SB_HORZ, WM_HSCROLL); UpdateScrollBar(SB_VERT, WM_VSCROLL); finally LinkedMemo.LinkedMemo := savedLink; end; end; procedure TForm1.FormCreate(Sender: TObject); begin Memo1.LinkedMemo := Memo2; Memo2.LinkedMemo := Memo1; end; end. Edited Monday at 05:42 PM by limelect Share this post Link to post
limelect 51 Posted Monday at 05:50 PM I suspect that if a customer of yours will come and say on one computer it works on another it does not what will you do? Share this post Link to post
limelect 51 Posted Monday at 05:58 PM @Uwe Raabe Checked yours and the horizontally does not work. It seems that my last zip is the only one except mouse wheel Share this post Link to post
Kryvich 168 Posted Monday at 06:40 PM @limelect How do you scroll horizontally? I know some programs allow this by holding the shift key down while you operate the scroll wheel. But in our case it doesn't work. I can scroll horizontally by dragging the bottom slider on the scroll bar, or by moving the cursor to the end of the line with the keys. Share this post Link to post
limelect 51 Posted Monday at 08:06 PM (edited) I use the scroll bars,Home,end,all arrows ,Page up and down ALL WORK ON MY LAST ZIP In All your software guys all keys did not work but mouse weel did. In my case all keys work except mouse weel. I tested all your versions. So may be you can take my solution and fix it for the mous weel? I guss windows version do give a problem but why my version work? Edited Monday at 08:10 PM by limelect Share this post Link to post
JohnLM 27 Posted Monday at 08:56 PM (edited) specs: Delphi XE7, VCL, Win7 laptop -- syncing two memo's scrolling via cursor keys and mouse -- Success #2 !! I was busy in another project these past few days. Uwe's first version works as requested. I did not think to add additional keys and mouse features at the time. Later, someone else asked for further features. Today, I tested the rest of the posted versions from Uwe, and the last one from Kryvich (his post from Monday 7:06am, page 1). Here is my list of what works successfully for scrolling inside the two memo's under Windows 7 using Kryvich's code snippet: * scrolling Up/Down, Left/Right via cursor keys * scrolling Up/Down via PageUp/Down keys * scrolling Up/Down via mouse wheel while clicked inside any of the memo's. * scrolling Up/Down/Left/Right via mouse click-and-dragging up/down on the verticle scrollbars * scrolling Left/Right via mouse click-and-dragging on the horizontal scrollbars In this scenario, the two memo's window or viewing size should be the same. One should not be larger in width, though it may not matter in some cases--I did try it by playing around with the Anchors and re-sizing one of the memo's at runtime. The scrolling will function accordingly, but at some point it will not because it runs out of scrolling space, which makes sense. So, keeping the window size the same for the memo's is beneficial for this feature. What does not work is scrolling Left/Right via mouse wheel via "rolling" the wheel. As far as I can tell, this was not asked about. But this feature is something I used in the good old days of the Opera browser, some 15 or 20 years ago, and then one day they took it out for good. You would press the Ctrl key while spinning the mouse wheel Up/Down in order to go left or right in the browser window. I miss this feature in a browser. The TMemo does not have this feature. But it would sure be nice if it did. The user would move the mouse pointer over the main thick scrollbar (the one inside, between the Left/Right scrollbars) and press and hold the Ctrl key and spin the mouse wheel to scroll left and right in the memo. Actually, if memory serves me, as long as I was in the document section or browser window with the mouse point, I could press and hold down the Ctrl and spinning the mouse wheel. I don't think it had to be on the scrollbar, or maybe it changed and you didn't have to be on the scrollbar anymore. And then they removed that whole feature. My thanks to both Uwe and Kryvich for providing the solutions to this aged old wish, going back to the early 2000's for me. Anyway. I am greatfull !! Edited yesterday at 08:36 AM by JohnLM typo/duplicate bullet, added new bullet Share this post Link to post
limelect 51 Posted yesterday at 09:10 AM (edited) @Uwe Raabe I took your last basics and left only the old SyncLink (see zip) and all work including mouse scroll P.S I tested your SyncLink and it messed the mouse BUT I FOUND THAT The little arrows on the horizontal scroll do not work They trigger SyncLink Everything else works like a charm and that is on Windows 7!!! MemoScrol.zip Edited yesterday at 09:14 AM by limelect Share this post Link to post
limelect 51 Posted yesterday at 09:33 AM I found that horizontal or vertical scroll triggers differently from the little arrows !!!! Share this post Link to post
limelect 51 Posted 45 minutes ago (edited) @Uwe Raabe I know the problem but could not find a solution On the horizontal arrow, you need to move in SyncLink by character I tried MyChar := Perform(EM_POSFROMCHAR, 0, 0); LinkChar:= LinkedMemo.Perform(EM_POSFROMCHAR, 0, 0); if LinkChar<>MyChar then LinkedMemo.Perform(EM_SCROLLCARET, 0, ?); but the char position is not correct one has to find the char position from the line? Any idea? Furthermore if one scrolls by char he does not scroll by line P.S. I computerize large companies but this little piece of software helps stay in shape of mind. Edited 40 minutes ago by limelect Share this post Link to post