TRichEditView has built-in support for left-aligned, right-aligned and centered paragraphs, which correspond to the PFA_LEFT, PFA_RIGHT and PFA_CENTER values for the PFM_ALIGNMENT flag in the PARAFORMAT2 structure , but does not have support for PFA_JUSTIFY and PFA_FULL_INTERWORD.
Wiki: OWLNext_Roadmap_and_Prereleases
Anonymous
Afetr more research and experiments, it turned out that I am unable to successfully use PFA_JUSTIFY (and that PFA_FULL_INTERWORD is defined to be the same as PFA_JUSTIFY).
An answer to a post on StackOverflow indicated that the message EM_SETTYPOGRAPHYOPTIONS needs to be sent to the rich edit control with the flag TO_ADVANCEDTYPOGRAPHY, but even with that I cannot get it to work. Maybe I am missing something ...
There is one more piece of the equation - to use justified text and word wrapping in a rich edit control, first EM_SETTARGETDEVICE must be sent to the control.
But the second parameter for that message is the line width, and it is not clear in what units it should be, as it is not in pixels? If printing, then it can be set to the result of
GetDeviceCaps(hdc, PHYSICALWIDTH)
. But when we simply want to justify on the screen, what is the relation between the window width and the line width?Okay, it is very counter-intuitive, but calling SetTargetDevice(NULL, 0) enables word wrapping in TRichEdit control, and allows PFA_JUSTIFY to work correctly.
Hi Ognyan, good work on this!
Just looked at [r6604], and I see
== TRUE
. This is something code analysis tools will flag as a potential issue, since the underlying type is int. Although the EM_SETTYPOGRAPHYOPTIONS documentation is clear that it will definitely return TRUE (often the documentation says "return non-zero" or something to that effect), the fail-safe test is!= FALSE
.PS. There is also
owl::ToBool
(defined in "owl/private/defs.h"), which performs a fail-safe static_cast.Related
Commit: [r6604]
Last edit: Vidar Hasfjord 2023-09-20
Ognyan, I get a build error now. I think you forgot to add a file:
Oh, right :-(
Added now.