Forum > Windows

Need help with ScrollWindowEx

<< < (9/9)

rick2691:
I have found one short coming by using either of the WM_VSCROLL or KeyInput methods: both can round out and go one line over or one line under its target.

I haven't found any way to avoid that.

Rick

rick2691:
I have found a better method. By being in the btnExit procedure there was always a second paint by either subroutines or Mouse and Key events. Too hard to track down, and is probably vital to other routines. So I decided to build an independent procedure that btnExit can call. As it turns out it is one of the Scrollbar functions, and the simplest to use; plus it has a high precision; no over and under issues.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TCmdForm.ScrollMemo(TempMemo:TRichMemo; BarType:string; BarTgt:longint);//  TempMemo: RichMemo Document * Bartype: 'Vrt' or 'Hrz' * BarTgt: ScrollBar Position//  example ScrollMemo(PageMemo, 'VRT', 12452);var BarPos: LongInt;beginif upcase(BarType)='VRT' then  // vertical   begin   BarPos:= GetScrollPos(TempMemo.handle,SB_VERT);    if BarPos>BarTgt then  // scrolls document to last cursor position      Begin                      // as per its previous screen view      while (BarTgt<GetScrollPos(TempMemo.handle,SB_VERT)) do             begin             TempMemo.VertScrollBar.Position:= TempMemo.VertScrollBar.Position - 1;              {             ** Alternative method, but can roundout to under of over the target **             //KeyInput.Apply([ssCtrl]);   // use to include CtrlKey etc.             KeyInput.Press(VK_UP);  // simulate press of F1 function key             KeyInput.Up(VK_UP);    // simulate release of UpArrow key             //KeyInput.Unapply([ssCtrl]);  // use to release CtrKey etc.             }              {             ** Alternative method, but can roundout to under of over the target **             SendMessage(TempMemo.handle, WM_VSCROLL, MAKELONG(SB_LINEUP, 1), longint(0));             }             end;      end else          Begin          while (BarTgt>GetScrollPos(TempMemo.handle,SB_VERT)) do                 begin                 TempMemo.VertScrollBar.Position:= TempMemo.VertScrollBar.Position + 1;                 end;          end;  // end of else   end; // end VERTICAL BarType if upcase(BarType)='HRZ' then  // horizontal   begin   BarPos:= GetScrollPos(TempMemo.handle,SB_HORZ);    if BarPos>BarTgt then  // scrolls document to last cursor position      Begin                      // as per its previous screen view      while (BarTgt<GetScrollPos(TempMemo.handle,SB_HORZ)) do             begin             TempMemo.HorzScrollBar.Position:= TempMemo.HorzScrollBar.Position - 1;              {             ** Alternative method, but can roundout to under of over the target **             //KeyInput.Apply([ssCtrl]);   // use to include CtrlKey etc.             KeyInput.Press(VK_LEFT);  // simulate press of F1 function key             KeyInput.Up(VK_LEFT);    // simulate release of UpArrow key             //KeyInput.Unapply([ssCtrl]);  // use to release CtrKey etc.             }              {             ** Alternative method, but can roundout to under of over the target **             // SendMessage(TempMemo.handle, WM_HSCROLL, MAKELONG(SB_LEFT, 1), longint(0));             }             end;      end else          Begin          while (BarTgt>GetScrollPos(TempMemo.handle,SB_HORZ)) do                 begin                 TempMemo.HorzScrollBar.Position:= TempMemo.HorzScrollBar.Position + 1;                 end;          end;  // end of else   end; // end HORIZONTAL BarTypeend; 
Rick

rick2691:
Et. Al.

What bothers me is that I can do

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TempMemo.VertScrollBar.Position:= TempMemo.VertScrollBar.Position - 1; creeping up one pixel at a time to BarTgt, and it is perfect, but I cannot do

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TempMemo.VertScrollBar.Position:= BarTgt; It is evidence of severe disfunction, because it does nothing.

Navigation

[0] Message Index

[*] Previous page

Go to full version