The constructor TCharFormat (ulong mask) sets cbSize = sizeof(::CHARFORMAT). It should use the base class CHARFORMAT2 here.
This issue was silently fixed on the trunk in [r5853] as part of other TCharFormat improvements.
Note that this bug may lead to issues with features of the TRichEdit control not working as they should.
Reported by @damonregister [discussion:d7e28a3b2e].
Commit: [r5853]
Discussion: d7e28a3b2e
Discussion: TRichEdit background color OWL 7.0 vs 7.1
Wiki: OWLNext_Roadmap_and_Prereleases
Perhaps I didn't express well in my post to the forum. The constructor TCharFormat correctly sets cbSize to sizeof(CHARFORMAT2) while the GetCharFormat does not set the size correctly.I just re-read your post and realized I forgot about the 2 overloaded constructors. The one works while guess the other doesn't. Thanks for submitting this bug.
Last edit: Vidar Hasfjord 2024-10-04
@damonregister wrote:
Yes, exactly! As I wrote in [discussion:d7e28a3b2e], the constructor TCharFormat (ulong mask) sets
cbSize = sizeof(::CHARFORMAT), which is a bug, while the (deprecated) constructor TCharFormat (const TRichEdit& edit, bool selection, ulong mask) correctly setscbSize = sizeof(CHARFORMAT2).And note that TRichEditor::GetCharFormat (TCharFormat & cf, bool selection) does not set the cbSize field of the passed TCharFormat instance, but relies on how it has been initialised.
Workaround
In version 8, you'll be able to simply use our new functional-style overload:
Thanks for reporting the issue and identifying the bug!
Related
Discussion: d7e28a3b2e
Last edit: Vidar Hasfjord 2024-10-05
Note that this bug has been present since 6.04, and that the buggy implementation of the constructor TCharFormat (ulong mask) was inlined in "richedit.h" [r5] until it was corrected and moved to "richedit.cpp (sourceforge.net)" [r5853] on the trunk (version 8).
Since the bug is inlined, and the fix hence requires a full recompile of all client code (and hence isn't ABI compatible), we cannot merge this fix into any of our LTS releases (6.30, 6.36 and 6.44). Nor can we merge it into 7.0, although we can of course bump the current release version to 7.1, if there is demand for an immediate fix. For now, I have set the milestone to version 8, leaving users of older versions to apply the workaround mentioned earlier.
Related
Commit: [r5]
Commit: [r5853]
Last edit: Vidar Hasfjord 2024-10-05