Prev: API-Guide
Next: Find Addin
From: Bee on
I cannot get my RTB to wrap properly.
I am set for vert scrollbar or both with (fiddled with each)
The text does wrap bu not at the end of the actual proper point.
Several words ar off screen right.
As I resize, the text wrap changes but still leaves several words off the
right side.
I tried setting right margin with no luck.
Must be something else I amd not doing.
I tried different fonts: MSSANSERIF, Arial and Lucida Console(preferred).
The text is loaded from a .rtf file created in MS WordPad since I do use
Bold and Underline in the text. The text has also been through Word 2003 and
also OpenOffice Writer. Does that do something bad?

If I run through Notepad I will loose all my text formatting so I would
rather not do that.

From: Bee on
I have tried these two methods and neither one works.
Both still leave text past the vertical scrollbar. No horz scrollbar.

(A)
Public Sub RTBWordWrap(RTB As RichTextBox, Optional bSet As Boolean = True)

If bSet Then
' then to set word wrap, use this :
SendMessageLong RTB.hwnd, EM_SETTARGETDEVICE, 0, 0
Else
' and to do the oposite use this one :
SendMessageLong RTB.hwnd, EM_SETTARGETDEVICE, 0, 1
End If

End Sub 'RTBWordWrap

(B) in _Resize
RichTextBox.RightMargin = RichTextBox.Width
If I do
RichTextBox.RightMargin = RichTextBox.Width * .75
this woks better for wide RTB but when the RTB gets narrow, words again go
past the vert scrollbar.

Does this have to do with thiings like Bold etc that may not be accounted
for correctly?

I am using rich text not plain text.

From: JPB on
Do you want the RTB to wrap text at the right-edge (or before the left
edge of the vertical scrollbar) no matter what the width of the RTB?
If so, setting the RightMargin property to 0 works for me. If this
doesn't work for you, what OS are you using? What version of
richtx32.ocx do you have?
From: Mayayana on
| SendMessageLong RTB.hwnd, EM_SETTARGETDEVICE, 0, 0
| Else
| ' and to do the oposite use this one :
| SendMessageLong RTB.hwnd, EM_SETTARGETDEVICE, 0, 1


That version works for me. I'm using RichEdit v. 2/3 rather
than the OCX, but I doubt that matters.
You said you have no horiz. scrollbar. How would you *not*
have wordwrap if there's no horiz. scrollbar? And how could you
provide an option if there's no horiz. scrollbar?


From: Mayayana on
I just looked up what I'd used when I was using the
OCX. Like JPB, I was setting RightMargin to 0 for
wrap and setting it to 50,000 for no wrap. I don't
think you have to deal with resizing.

According to the docs:

The default for the RightMargin property is 0 and will cause the control to
set text wrapping equal to the right most part of the RichTextBox control so
all text is viewable.

If you're doing
RichTextBox.RightMargin = RichTextBox.Width * .75
that's giving you 3/4 of the RTB width beyond the
RTB for text. If you have some long lines that can
cause partial wordwrap.


 |  Next  |  Last
Pages: 1 2 3 4
Prev: API-Guide
Next: Find Addin