Richedit justify and numbering style bugs and fixes
Posted: Wed Oct 22, 2014 12:16 pm
I have been using HMG rich edit controls heavily for the past few months and have discovered two bugs and fixes for them.
The first bug is that the justify alignment does not work, e.g.
Win.RichEditBox.ParaAlignment := RTF_JUSTIFY
has no effect and does not actually justify the text. After some searching, I found out that you must turn on "advanced typography" to get this to work. The following should be added to InitRichEditBox() in c_richeditbox.c:
SendMessage( hWndControl, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY );
"Advanced typography" sounds like it should be enable a big set of advanced features, but in fact the feature set it enables is quite small, and justification is the main one.
The second bug is that paragraph numbering styles that you get and set with the ParaNumberingStyle property do not match the constants in i_richeditbox.ch, e.g.
Win.RichEditBox.ParaNumberingStyle := RTF_PERIOD
actually sets the numbering style to two parentheses instead of a period. This is due to a mismatch between c_richeditbox.c lines 837-845 and 940-953, and i_richeditbox.ch lines 151-157. In the C code, numbering style 0 and PFNS_PAREN have the same effect, a right parenthesis after the number. So the first case is unnecessary, and the cases should start with PFNS_PAREN, which should be mapped to case 1.
However, I do not think the C code should be modified, as this would break existing applications that use it. Instead, I suggest adding some additional constants to i_richeditbox.ch that reflect the actual values in the C code, e.g.
#define RTF_PAREN_2 3 // Follows the number with a right parenthesis.
I've put suggested fixed versions of i_richeditbox.ch and c_richeditbox.c onto my web site at http://kevincarmody.com/hmg/" onclick="window.open(this.href);return false;
Kevin
The first bug is that the justify alignment does not work, e.g.
Win.RichEditBox.ParaAlignment := RTF_JUSTIFY
has no effect and does not actually justify the text. After some searching, I found out that you must turn on "advanced typography" to get this to work. The following should be added to InitRichEditBox() in c_richeditbox.c:
SendMessage( hWndControl, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY );
"Advanced typography" sounds like it should be enable a big set of advanced features, but in fact the feature set it enables is quite small, and justification is the main one.
The second bug is that paragraph numbering styles that you get and set with the ParaNumberingStyle property do not match the constants in i_richeditbox.ch, e.g.
Win.RichEditBox.ParaNumberingStyle := RTF_PERIOD
actually sets the numbering style to two parentheses instead of a period. This is due to a mismatch between c_richeditbox.c lines 837-845 and 940-953, and i_richeditbox.ch lines 151-157. In the C code, numbering style 0 and PFNS_PAREN have the same effect, a right parenthesis after the number. So the first case is unnecessary, and the cases should start with PFNS_PAREN, which should be mapped to case 1.
However, I do not think the C code should be modified, as this would break existing applications that use it. Instead, I suggest adding some additional constants to i_richeditbox.ch that reflect the actual values in the C code, e.g.
#define RTF_PAREN_2 3 // Follows the number with a right parenthesis.
I've put suggested fixed versions of i_richeditbox.ch and c_richeditbox.c onto my web site at http://kevincarmody.com/hmg/" onclick="window.open(this.href);return false;
Kevin