Font_ScanString problem
Andrew Weighill (5123) 13 posts |
I’ve created a multiline textbox, using Font_ScanString to find the number of characters which will fit in the available space and then breaking on a space or if no space then calling it again without the separator, painting the line and then going again for the remaining bytes in the string. This is working well when the window is active, but redraws after the window has been obscured are causing some strange behaviour. Specifically Font_ScanString returns a greater value for the number of characters that can be fitted in, despite being given the same inputs, this results in the string being (invisibly) painted beyond the window boundary.
Reporter output for a foreground redraw
Note the two lines of text, one of 7 characters and one of 6 characters. Now for the output from a background redraw:
Exactly the same inputs, but this time it thinks that all 13 characters can be painted in the width available, they can’t :-( Any ideas? What am I doing wrong! |
Stuart Swales (8827) 1357 posts |
scanflags% needs bit 8 set for Font_ScanString to use the font handle in R0, otherwise it’s sizing using whatever happens to be current. If you add that, consider using it for Font_Paint as well, supplying the font handle in R0 to save the Font_SetFont calls. Remember to advance over the space as well if you’ve split on that. |
Martin Avison (27) 1494 posts |
Aside: when using Reporter the output is often clearer if you use |
Andrew Weighill (5123) 13 posts |
Stuart, yes setting bit 8 sorted it. I will also take your suggestion for Font_Paint, thank you. Martin, I’ve found your Reporter program invaluable, particularly figuring out the different co-ordinate systems, being able to see the values returned in various places has made things a lot easier. Thanks for the tip for getting things listed on a single line. |