I sandwich operations between LockWindowUpdate on the parent
window. I also sometimes add EnableWindow on the RichEdit itself.
I'll find out, I guess. I'm setting it for both, since
it's possible someone here would be curious.
I used to visit maybe 6-7 programming groups
I don't see how that's possible.
Did you also save and reset the SelStart position?
If you do as above but end up with SelStart (cursor pos)
several lines away, then it will jump.
The button? You click a button to run the test?
I don't know whether that might affect it, since
it takes focus from that window.
But I'm not really understanding what you're doing,
or why you need a button.
GETSCROLLPOS is not the same as cursor position.
Cursor position is EM_EXGETSEL and EM_EX_SETSEL.
SCROLLPOS is the scrolled position of the RichEdit window
in relation to the upper left corner.
How about if you just do the operation you want without
the button? In other words, do what you actually want to
do with the text.
If you change the actual text then of course you'll need to
account for that.
... I wanted to remove as much as non-essential code as possible (the
actual saving on close and loading on opening the program) so it could
not interfere (read: cause the problem).
But I doubt it's doing anything but changing
the theoretical height of the window
If it were me I'd lock the window, load the file, set the
cursor position, then unlock.
If you want to keep doing it as you're doing it then maybe
start eliminating factors more.
For instance, you could load the file from within code.
I'm not clear about the dialogue. You're making your own window?
You're still not using quite the right terminology, if you say the problem right it
might be easier to solve :-)
If you try to set the scroll position to a place where the carat won't actually be visible
in the window, my understanding is that it will scroll to a different
place instead where
the carat will be visible.
So you want to set the carat position in the text before you try adjusting the scroll to
show the part of the text you desire.
This may be the source of your difficulties.
GETSCROLLPOS is not the same as cursor position.Yes, that was my mistake in naming the problem. Its about saving/restoring the views position, not the cursor.
Cursor position is EM_EXGETSEL and EM_EX_SETSEL.
| In my case I describe a dialog in a resource file, and than load
| that resource using "call DialogBoxParamA,0, IDC_DIALOG,0,offset
| DialogCB,0"
I've never used that. I use GetOpenFileName, to
give me a system file-open window with all the fixings.
That might be good. I'm having trouble following.
I thought you said the problem was with loading a file,
I did find that it acts as you say. I don't know why.
When I get and set scrollpos it jumps, and each
additional operation moves the scrollpos up.
However, if I get and set the caret position it works fine,
Newyana2,
I did find that it acts as you say. I don't know why.
When I get and set scrollpos it jumps, and each
additional operation moves the scrollpos up.
Thank you for confirming it.
Now all I need to do is figure out how to fix it - if at all possible
(have seen it mentioned as a being bug).
I played with the VB code and found it seems to be a function of font size and window width. If the font size is not too large and the rich text box
is wide enough, the jumping doesn't occur. I don't know exactly what that relationship is. Very strange!
Apd,
I played with the VB code and found it seems to be a function of font
size and window width. If the font size is not too large and the rich
text box is wide enough, the jumping doesn't occur. I don't know exactly
what that relationship is. Very strange!
Thanks for looking into it. :-)
When you made the problem disappear by making the font smaller and the control wider, have you also tried to increase the ammount of loaded text (double the document) ?
The problem might be a function of the total height of the document. Both
of your changes lessen it.
My own guess that EM_EXLIMITTEXT is involved does also match the (updated, still guessed) "total height" possible cause : Limit the ammount of text
that can be loaded and you limit the hight of the document.
Hmm... I just tried to remove all line-ends within the paragraphs, but
still got the/my problem.
The larger the byte count, the worse it is.
It may very well be a bug. I've come across other bugs.
The end result ? The "no problem" -> "problem" point was when I changed
the number of lines in the file from 4096 to 4097. Yep, from 0x1000 to 0x1001. :-)
IOW, it looks like a magical number is involved, but MS "forgot" to
mention it.
It looks like its influencing the EM_GETSCROLLPOS. With 4095 lines the "view"s Y position is 0xFEFE, with twice the ammount of lines its 0xFF8F.
Not really twice as much height, wouldn't you say ? :-)
In a test I did, the jumping happened on exactly 4096 lines but only when EM_GETSCROLLPOS > 32768. Below 32768, the jumping stopped. This used short lines with no wrap in 10pt Courier New.
"The values returned in the POINT structure are 16-bit values (even in the 32-bit wide fields)".
What a mess!
Not all that bad. It leaves me room for about 60 -70
window heights worth of text. On the one hand, there
seems to be no excuse for limiting 32-bit values to
16-bit.
On the other hand, who needs 4000 lines of text with
formatting?
The real tragedy is that you're not finding a way to
get paid for your uncanny ability to find bugs. :)
I just come across them while I'm trying to create something.
And again doubling the number of lines caused the result become larger,
not smaller (0xDF58 -> FF6F).
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 42:20:32 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,857,793 |