On a windows mobile device I have a mutliline text edit control that is set to read-only and has some static text displayed during it’s display lifetime. I would like to only display a vertical scrollbar when it’s actually useful (i.e. the text is larger than the display).
I can’t easily figure out if the text is to large to display because of two reasons.
- There is no horizontal scroll bar displayed so the text wraps.
- Under windows mobile, the win32 routines to calculate the size of what text will display does not work correctly. They return a incorrect rectangle.
The edit control must tell the scroll bar what it’s scroll range is at some point. I was wondering if I could get in between then and hide the scroll bar if it’s not going to be used.
This is how I solved this problem.
First off:
Solution:
I have a standard CEdit bound to the control.
During the InitDialog and OnSize calls, turn on the display of the scroll bar and setup a timer message.
In the timer handling code, use the scroll information to determine if the scroll bar needs to be displayed.
If not being displayed, turn off the scroll bar and force the window to redisplay.
I hope that helps out other people who may have similar requirements.