0

I'm recently working on a text editor application using RichTextBox. I'm able to divide the user's input text into multiple pages when the text content size is bigger than the page size by taking the overflowing text into another page. The paragraphs are well justified right-to-left and left-to-right except for the last line in the last paragraph when I'm taking that overflowing text into the newly created page. This line should be justified like the other lines in the same paragraph because it has another part in the next page.

I know I can use space mono fonts and replace the blank spaces with measured size of space characters. But it seem to cause another font problem inside the text.

How can I make that last line justified to the end of page width?

  • I do not understand what you are asking. User is giving input. Then you press a button to format the input? do youhae any code? – Aldert Jul 28 '19 at 07:39
  • This effect is built-in RichEdit Control 2.0+. But is not available in the .Net implementation (RichTextBox), because the RichEdit Advanced Typographics option are disable. You can re-enable the TOM sending a `EM_SETTYPOGRAPHYOPTIONS` message with `TO_ADVANCEDTYPOGRAPHY`. At this point, the effect specified in [PARAFORMAT2](https://docs.microsoft.com/en-us/windows/win32/api/richedit/ns-richedit-paraformat2_1) are processed again. You can see [an example here](https://stackoverflow.com/a/47470191/7444103), a RichTextBox control where the Justify Paragraph (Block-Align) alignment is re-enabled. – Jimi Jul 28 '19 at 10:18
  • See in `PARAFORMAT2` the effects of `PFE_KEEP` and `PFE_KEEPNEXT` (note that these style are also implemented in the underlying RTF text), the [EM_SETWORDBREAKPROC](https://learn.microsoft.com/en-us/windows/win32/controls/em-setwordbreakproc) message and the [EDITWORDBREAKPROC](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nc-winuser-editwordbreakprocw) callback. You'll find the documentation lacking in details on these typographics options, though. I'll update that custom control sooner or later with these options (too much code for SO for now). – Jimi Jul 28 '19 at 10:24
  • Hi ! Aldert, I'm looking for a way to do what a "Shift+Enter" does on MS Word justified text. It divides the paragraph but also keep the broken line justified (stretched to reach the page edge/margin even if it contains tow words only). – Muhammed Abdulmajid Oct 27 '19 at 15:04
  • Hi ! Jimi, I looked in the Microsoft documentation and it seems PFE_KEEP and PFE_KEEPNEXT only appear on printing and do not affect the text editing.I looked also to see how I can use EM_SETWORDBREAKPROC and EDITWORDBREAKPROC but I couldn't understand if they meet my needs – Muhammed Abdulmajid Oct 27 '19 at 15:11

0 Answers0