Forum > Windows
Need help with ScrollWindowEx
rick2691:
Martin,
Setting the ScrollBar position does not change anything. ScrollWindowEx is basically what happens when you drag the ScrollBar button or click up/down buttons. My setting the position value does not trigger a scrolling action. Neither does ScrollWindowEx until I send GetVrtOK:= UpdateWindow(PageMemo.handle);
That scrolls the text. But what I need is to how to fill out the data list in ScrollWindowEx. So I am appealing to everyone who ever used the function. I have not been able to find any information that explains what each entry is doing. However, I have found that they should all be set to NULL.
In particular the settings that I have shown as @AreaRect, which was only a stab at making something happen. I am sure that @AreaRect is not what needs to happen. I stuck an @ on it because they want a pointer. I don't think that you can point to a variable, but I tried it. It doesn't work, but it did not cause an error message either.
Please don't try to get me to do something else. If you don't know how to fill in the data, please just wait for someone who does.
Rick
Martin_fr:
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-scrollwindowex
Mind on non-Win platforms (qt,gtk,cocoa) only subsets of the documented behaviour may be implemented.
IIRC (but not 100%) "prcScroll" is the source rect.
The dest rect is then calculated by adding dx/dy. But any part of the dest rect that is outside "prcClip" is NOT painted.
hrgnUpdate => not sure. Some Windows thing, may not work on other platforms. Keep it nil.
prcUpdate : as it said, the invalidated rectangle.
Any part of the dest-rect for which there are no (valid) src pixels. Could be scrolled in from outside the client area. Or could be scrolled in from an already invalidated area.
Usually not needed, rather set SW_INVALIDATE and there will be a paint event for this, after the scrolling.
SW_SCROLLCHILDREN if there are child windows (with a window handle, eg a panel / but must be children) in the rect, they will be moved.
So if you just set
- the handle
- dx / dy
- all else nil
then you will scroll the entire clientarea.
If not, then either
- you have the wrong handle
- the (entire) client area was invalidated (waiting for a paint)
- there is a paint event undoing the scroll, before you even can see it.
If the function returns an error =>
- on windows, check msdn website
- on other widgetset, check if ScrollWindowEx is implemented at all.
Martin_fr:
--- Quote from: rick2691 on February 23, 2023, 08:28:16 pm ---Please don't try to get me to do something else. If you don't know how to fill in the data, please just wait for someone who does.
--- End quote ---
Just for background: I wrote the code in SynEdit that calls ScrollWindowEx. And that works well. It does have a fallback to use paint, if for any reason the text can't be scrolled (e.g. is already invalidated, maybe because some other control painted on top of it).
Mind: At least on older Windows ScrollWindowEx can leave a ghost cursor (the text cursor / vertical blinking line). There is a comment towards that in the SynEdit Source.
In SynEdit, the code (SynEdit code, because ScrollWindowEx does none of those) that invokes ScrollWindowEx will set :
- the scrollbars to the correct new position
- The internal variable for "TopLine" that decides which line from the TextBuffer will be the first visible (otherwise SynEdit.Paint would undo the Scroll)
- Other internal values (such as the position of the text cursor)
Any Text that got "scrolled in" will be painted by SynEdit.Paint. SW_INVALIDATE is used for that.
rick2691:
Martin
--- Quote ---Just for background: I wrote the code in SynEdit that calls ScrollWindowEx.
--- End quote ---
Yes, I had seen your name.
Meanwhile, I have changed the code to the following. It doesn't throw any errors, but it also does not scroll the screen.
--- 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";}};} --- // var AreaRect: TRect; AreaRect:= rect(0,0,0,0); 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, SW_INVALIDATE); // boolean GetVrtOK:= UpdateWindow(PageMemo.handle); // must execute end else showmessage('VRT-SCROLLBAR FAILED 17');
The issue of setting those to nil, null, or zero is what I have been asking about. using the word "null' had thrown an error, and so had "nil", yet a zero was accepted. But with no functionality. So what would be the correct way of setting them.
Rick
Martin_fr:
--- Quote from: rick2691 on February 26, 2023, 06:05:00 pm ---
--- 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(0,0,0,0);
--- End quote ---
That is a rectangle with zero content. So nothing will be scrolled.
You could use the memos height/width in that rectangle, or probably just memo.clientrect.
But you don't need to.
I haven't checked the pascal definition (for nil versu 0).... But like this.
--- 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, // RichMemo application 0, // horizontal element (VrtBarPos - SetVrtPos), // old and new positions nil, // or clientrect nil, // or clientrect 0, // EDIT: definitely passing 0 here nil, // EDIT: nil or pointer to rect that will be written to SW_INVALIDATE); // boolean
Navigation
[0] Message Index
[#] Next page
[*] Previous page