Martin
I have understood what you have been saying ... the screen is a tablet that gets painted. It isn't a scroll like you have with a rolled up document. Its a simulation.
However, this painting is what happens when I use my mouse wheel or click and drag the elevator cabin in the scroll bar. That is the scroll that I want and expect.
Not exactly the same....
Well, it is possible that the memo (upon receiving a scrollbar action) actually calls ScrollWindowEx (so that part is the same). But the Scrollbar action does more.
In my example (form, memo, button, buttonClick event) ScrollWindowEx scrolls the content (except for a small area at the top or bottom, depending on direction). But in that example that scroll is temporary. It gets undone by the next paint.
If the memo text is
And the memo gets a WM_paint event, then the memo does
- what is my internal value for the first line to show.
-- That value will at some time before have been taken from the scrollbar.
-- Or it will have been changed by the use of cursor keys (a memo can scroll, even without scrollbars)
- The memo will then paint all pixels according to that internal value.
If the memo thinks "line 2" is first to be shown, it will show "line 2".
ScrollWindowEx is not informing the memo. So the internal value is not changed.
That is ok, if the memo itself did call ScrollWindowEx, because then the memo knows to update its internal value.
But if you call ScrollWindowEx, the memo does not know.
So if you call ScrollWindowEx, then "line 3" may be at the top. But the memo still believes it is "line 2", and in the next paint event it will undo the scroll.
Also (and you can see that with the example I described), ScrollWindowEx does not fill the "scrolled in" area => the memo does in a paint event. But the memo fills it with what it thinks should be there (and that is the unscrolled content).
---
You can call ScrollWindowEx on a TButton. And it will work. And the image of the button (not the button, only the image of the button) will be moved on the screen.
Of course a button has no concept of being scrolled. You would not expect the button to know when it has been scrolled.
Have you been saying anything different from that? The actual mechanics of the simulation are buried in the operating system. Yet I expect the ScrollWindowEx function to make that available to me.
No, ScrollWindowEx is not the mechanics of the memo's scrolling. It is just a tool that the memo can use as
part of its internal mechanics.
But it is just a small part. And if you execute it
without the other parts then it will not to the full job.
Equally TextOutA
https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-textouta may be part of what the memo uses (this or some equal function).
But if you do a TextOutA on the memos HDC (can be derived from the handle, IIRC), then that will not have a lasting effect. It will maybe draw something on the screen, but the next wm_paint will overpaint it. Because the memo never knew you put something there.
Moreover, that is exactly what my SendMessage(PageMemo.handle, WM_VSCROLL, MakeLong(SB_THUMBPOSITION, VrtBarPos), 0) function had already been providing me with. I need to have its functionality returned to me.
But that is a message that goes to the Memo. The memo will know that this happened (if it works). And so the memo will do
all the parts of scrolling. Including updating its internal values.
Unfortunately I do not know why it does not always work. Or if it is meant to work that way.
I am going to try your Button1Click procedure. It looks the same as what I have already tested. But since you have proven that it works with Windows 10 & 11, and if it doesn't on my computer, then I will have to track down what is boogering everything on my side.
It works as in
"It does temporarily scroll the image".
It does not do what you want it to do. It can not do what you want it to do. It is not meant to do that.
After this post
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.
I tried to show you "how to fill in the data".
Despite knowing that it wont help you. Despite that filling in the data correctly will simply not do what you want to be done.