Forum > Windows

Need help with ScrollWindowEx

(1/9) > >>

rick2691:
 
--- 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";}};} ---SendMessage(PageMemo.handle, WM_VSCROLL,  MakeLong(SB_THUMBPOSITION,  VrtBarPos)); 
       The above function is what I have used for years.
       It works for the RUN test by the compiler. It also
       works if I put the compiled EXE into a new folder.

       But once WINDOWS realizes that I have done this,
       they block the SENDMESSAGE function; ie. it just
       won't scroll anymore. This has developed recently,
       and I think it is a security issue by WINDOWS.
       So I am trying to implement the ScrollInfo method.

       Below is the ScrollWindowEx function. It is supposed
       to work, but I am misunderstanding its parameters.
       I also can't find any Pascal explanations for it.

       Lower is a SynEdit application from its unit. The
       compiler does not like the coding. Thus I am trying
       to translate it for the compiler environment.

       Lower again is a C code example by Windows. Lazarus
       doesn't like any of that!

       Can anyone show me how I should actually load
       ScrollWindowEx? Windows tells me that everything
       but the HANDLE and SET_POSITIONS should be NULL.
       Then you call UpdateWindow to make it happen.

       I suspect that the @AreaRect entries are improper.
       I also haven't found any information on the FLAGS.

       // VARIABLES
       // VrtBarPos:= SetScrollPos(PageMemo.handle, SB_VERT, VrtBarPos, TRUE); // integer
       // var AreaRect: TRect;
       // GetVrtOK: boolean;
       // SetVrtPos: integer;


--- 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";}};} ---       AreaRect:= rect(null,null,null,null);       SetVrtPos:= GetScrollPos(PageMemo.handle,SB_VERT); // integer        GetVrtOK:= ScrollWindowEx (PageMemo.handle,  // RichMemo application                                  0,  // horizontal element                                  (VrtBarPos - SetVrtPos), // old and new positions                                  @AreaRect,                                  @AreaRect,                                  0,                                  @AreaRect,                                  2); // boolean        GetVrtOK:= UpdateWindow(PageMemo.handle); // must execute       end else showmessage('VRT-SCROLLBAR FAILED 17'); 
       SynEdit Unit
       ScrollWindowEx (HWND=PageMemo.handle,
                       DX=0,
                       DY=(VrtBarPos - SetVrtPos),
                       PRCSCROLL=0x0,
                       PRCCLIP=0x0,
                       HRGNUPDATE=0,
                       PRCUPDATE=0x0,
                       FLAGS=2); // boolean

       Windows Example
       ScrollWindowEx(
       hWnd: HWND;
       dx: Integer;
       dy: Integer;
       prcScroll: PRect;
       prcClip: PRect;
       hrgnUpdate: HRGN;
       prcUpdate: PRect;
       flags: UINT
       ):Boolean;
       
       Scroll the window. The system repaints most of the
       client area when ScrollWindowEx is called; however, it is
       necessary to call UpdateWindow in order to repaint the
       rectangle of pixels that were invalidated.

       C CODE EXAMPLE:

--- 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";}};} ---       ScrollWindowEx(hwnd, -xDelta, -yDelta, (CONST RECT *) NULL,                     (CONST RECT *) NULL, (HRGN) NULL, (PRECT) NULL,                     SW_INVALIDATE);       UpdateWindow(hwnd);  

KodeZwerg:

--- Quote from: rick2691 on February 23, 2023, 03:46:31 pm ---I also can't find any Pascal explanations for it.
--- End quote ---
Since it is from the Windows API your only reference is the ScrollWindowEx and inside Windows SDK.

Martin_fr:

--- Quote ---
--- 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";}};} ---ScrollWindowEx (PageMemo.handle,
--- End quote ---

When you do that, you scroll the image on the screen. And that is all.

The memo never gets to know you did that. So once the memo repaints, it will paint the old content again.
You need to tell the memo, which line it should paint as the first visible line.


ScrollWindowEx is something you would use as part of your own custom control. When you implement the "paint" method yourself too.
ScrollWindowEx simply safes you from a full repaint, as it takes the pixels that are already painted, and moves those pixels. (Leaving it to you to update all internal states of the control)

rick2691:
Martin_fr


--- Quote ---The memo never gets to know you did that. So once the memo repaints, it will paint the old content again. You need to tell the memo, which line it should paint as the first visible line.

Leaving it to you to update all internal states of the control.

--- End quote ---

The (VrtBarPos - SetVrtPos) is what tells it to repaint as the first visible line. I am not changing the document. I am scrolling the document to match the setting I have installed on the ScrollBar. I may not understand what you are telling me ... but this function is updating the internal controls.

Rick

Martin_fr:
If you get the memo's own scrollbar pos "...VrtPos", and that scrollbar has changed, then the memo should scroll on it's own => why do you need ScrollWindowEx at all?

ScrollWindowEx will only have an affect until the next paint event of the memo. It is a one time paint to the memos visible area on the screen. It does nothing else at all.

SO:
- if the memo does change (without ScrollWindowEx) what it will paint as first line => then the memo will paint that, an the only effect that ScrollWindowEx has, is that it gets painted a tiny bit earlier.
- if the memo does not change (without ScrollWindowEx) what it will paint as first line => then ScrollWindowEx will cause the memo to display its content "moved up/down" and a few milliseconds later will be completely undone by the next paint.

In other words ScrollWindowEx does nothing but at best flicker your display once.

Navigation

[0] Message Index

[#] Next page

Go to full version