|
-
Oct 31st, 2000, 05:55 AM
#1
Thread Starter
Member
what's the code i f want to make my text in richtextbox justifed?
-
Oct 31st, 2000, 07:06 AM
#2
_______
<?>
'to align your text use this before you load the text
RichTextBox1.SelAlignment = 0 'left
RichTextBox1.SelAlignment = 1 'right
RichTextBox1.SelAlignment = 2 'center
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 31st, 2000, 01:56 PM
#3
but you cant justify both left and right margins simultaneously in the same paragraph
-
Oct 31st, 2000, 04:24 PM
#4
You can also use the constants rtfLeft, rtfRight and rtfCenter for your alignment.
-
Oct 31st, 2000, 08:49 PM
#5
This is the million dollar question. 
I've been battling with this and hyphenation (collectively known as H&J or hyphenation and justification) for a while.
As yet, I haven't got it going, but that could be cos I've stuffed things up.
If you are using version 2.0, 3.0 or 4.0 of the richedit dll (called riched20.dll NOT riched32.dll, which is the older non-international version), then you should be able to justify text.
While the full justify is not an option in the RichTextBox properties, there is a message that is supposed to work:
Theoretically, sending the EM_SETPARAFORMAT meaasge with a PARAFORMAT2 structure, with the Alignment mask set should justify the text. eg:
(N.B. Parts of this code have been ripped from vbaccelerators RichTextEdit control, which is supposed to support full justify, but doesn't, at least not on my machine)
Code:
Public Const PFA_LEFT = 1
Public Const PFA_RIGHT = 2
Public Const PFA_CENTER = 3
Public Const PFA_JUSTIFY = 4 'New paragraph-alignment option 2.0
Public Const MAX_TAB_STOPS = 32&
Public Const lDefaultTab = 720&
Public Type PARAFORMAT2
cbSize As Integer
wPad1 As Integer
dwMask As Long
wNumbering As Integer
wReserved As Integer
dxStartIndent As Long
dxRightIndent As Long
dxOffset As Long
wAlignment As Integer
cTabCount As Integer
'rgxTabs(0 To MAX_TAB_STOPS - 1) As Byte
'lPtrRgxTabs As Long
lTabStops(0 To MAX_TAB_STOPS - 1) As Long
dySpaceBefore As Long ' /* Vertical spacing before para */
dySpaceAfter As Long ' /* Vertical spacing after para */
dyLineSpacing As Long ' /* Line spacing depending on Rule */
sStyle As Integer ' /* Style handle */
bLineSpacingRule As Byte ' /* Rule for line spacing (see tom.doc) */
bCRC As Byte ' /* Reserved for CRC for rapid searching *
wShadingWeight As Integer ' /* Shading in hundredths of a per cent */
wShadingStyle As Integer ' /* Nibble 0: style, 1: cfpat, 2: cbpat */
wNumberingStart As Integer ' /* Starting value for numbering */
wNumberingStyle As Integer ' /* Alignment, roman/arabic, (), ), ., etc.*/
wNumberingTab As Integer ' /* Space bet 1st indent and 1st-line text*/
wBorderSpace As Integer ' /* Space between border and text (twips)*/
wBorderWidth As Integer ' /* Border pen width (twips) */
wBorders As Integer ' /* Byte 0: bits specify which borders */
' /* Nibble 2: border style, 3: color index*/
End Type
Public Const EM_SETPARAFORMAT = (WM_USER + 71)
'Code to actually align the text
Dim lusrPara As PARAFORMAT2
Dim lRetVal As Long
lusrPara.dwMask = PFM_ALIGNMENT
lusrPara.cbSize = Len(lusrPara)
lusrPara.wAlignment = PFA_JUSTIFY
lRetVal= SendMessage(RichTextBox1.hWnd, EM_SETPARAFORMAT, 0, lusrPara)
In theory, that code should work (Incedentally, using the paraformat2 structure is how you are supposed to be able to make the little animations you can in word. The paraformat2 structure supports every function found in Word97 Paragrah dialog.)
But for some reason, I can't get it going. It is possible that the call is working, but the rich text box is refusing to draw it.
The other option to do this stuff, (and if you work it out, drop me a line), is to use the Text Object Model, which is really only a wrapper around the riched20 messages.
Well, milad, that's all I can tell you. I'm battling with the same problem as well, and if I find a magic answer, I'll post it for you
cheers
- gaffa
-
Jan 12th, 2004, 04:39 AM
#6
Junior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|