Question, do you send the text string to the control, or does a user input?
If you send it to the control, and no user will modify it, format the string first.
If the user inputs on the fly, maybe look into
EM_SETWORDBREAKPROC Message
Replaces an edit CONTROL's default Wordwrap function with an application-defined
Wordwrap function. You can SEND this message TO either an edit CONTROL OR a
rich edit control.
EditWordBreakProc
An application-defined CALLBACK FUNCTION used WITH the EM_SETWORDBREAKPROC message.
A multiline edit CONTROL OR a rich edit CONTROL calls an EditWordBreakProc FUNCTION
TO BREAK a LINE OF text.
FUNCTION EditWordBreakProc(...)
SELECT CASE wActionCode
CASE %WB_ISDELIMITER
CASE %WB_LEFT
CASE %WB_RIGHT
END SELECT
END FUNCTION
Announcement
Collapse
No announcement yet.
Multi-line textbox with fixed-width word-wrap and scrollbar
Collapse
X
-
Originally posted by Mark Downs View PostI need a multi-line textbox that accepts no more than 80 fixed-width characters per line.
When a line reaches 80 characters, it should word wrap. I am also limited on real-estate and only able to display the left half of the textbox, so I need a horizontal scroll bar so the user can scroll the text into view.
If a single line TB, the character limit per line can be set by sendingCode:Control Send hdlg, %Id, %EM_SETLIMITTEXT, [B]80[/B], 0
===============================
"A man can't be too careful
in the choice of his enemies."
Oscar Wilde (1854-1900)
===============================
Leave a comment:
-
Try the EM_SETRECT message. Calculate the width of your RECT based in the font (GetTextExtent32()) so that what will fit will be 80 characters.
OR
Subclass the control and on each character calculate where you are relative to your 80 character limit; if over, scan backward for an allowed word-break character, and insert a line feed at that point.
The scrollbar is simply style WS_HSCROLL.
Leave a comment:
-
Multi-line textbox with fixed-width word-wrap and scrollbar
I need a multi-line textbox that accepts no more than 80 fixed-width characters per line. When a line reaches 80 characters, it should word wrap. I am also limited on real-estate and only able to display the left half of the textbox, so I need a horizontal scroll bar so the user can scroll the text into view.
Any ideas? Thanks in advance.Tags: None
Leave a comment: