Page 1 of 1

Richedit justify and numbering style bugs and fixes

Posted: Wed Oct 22, 2014 12:16 pm
by kcarmody
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

Re: Richedit justify and numbering style bugs and fixes

Posted: Wed Oct 22, 2014 12:35 pm
by serge_girard
Thanks Kevin !

Serge

Re: Richedit justify and numbering style bugs and fixes

Posted: Wed Oct 22, 2014 1:27 pm
by EduardoLuis
Hi Kevin:

My first words are: EXCELLENT job.-
I've download and apply new libraries, and it works absolutely fine.-
A suggestion to all users:
1) First rename both original files to individualitate as OLD
2) Copy both libraries each on it's root (INCLUDE and SOURCES)
3) Re Build libraries twice: one choosing ANSI option, and when it finish choose UNICODE
After that, chances take place and you'll enjoy both improvements.

Again Kevin, Excellent Job, and thanks to share with us.-
With regards.
Eduardo

Re: Richedit justify and numbering style bugs and fixes

Posted: Wed Oct 22, 2014 2:06 pm
by esgici
kcarmody wrote:I have been using HMG rich edit controls heavily for the past few months ...

I've put suggested fixed versions of i_richeditbox.ch and c_richeditbox.c onto my web site at http://kevincarmody.com/hmg
...
Hello Mr. Carmody

You are welcome aboard of HMG_Forum :)

Thanks a lot for your valuable participation.

And surely we will benefit by your huge experience and knowledge :arrow:

Happy HMG'ing :D

Re: Richedit justify and numbering style bugs and fixes

Posted: Wed Oct 22, 2014 2:37 pm
by danielmaximiliano
Gracias / Thanks Kevin....

Richedit justify and numbering style bugs and fixes

Posted: Wed Oct 22, 2014 3:14 pm
by Pablo César
Wow ! Thank you Kevin for you fix of it and sharing with us.

Have you are welcome to our community ! :D

Nice work in AksharaPad !

Image

Re: Richedit justify and numbering style bugs and fixes

Posted: Wed Oct 22, 2014 6:00 pm
by kcarmody
Thank you everyone for your kind words -- including Pablo for noticing my HMG project AksharaPad -- but it looks now like I was wrong about the second bug. There is no mismatch between the constants in i_richeditbox.ch lines 151-157 and the code in c_richeditbox.c lines 837-845 and 940-953. So the second bug I reported does not exist.

However it is still true that RTF_NONE and RTF_PAREN (style numbers 1 and 2) produce the same effect, a right parenthesis. So RTF_NONE is not necessary and is misnamed. The numbering style which eliminates punctuation is RTF_NONUMBER.

I've posted a new version of i_richeditbox.ch, with the proposed additions of RTF_PAREN_2 etc. removed, to my site at http://kevincarmody.com/hmg/" onclick="window.open(this.href);return false;

Kevin

Re: Richedit justify and numbering style bugs and fixes

Posted: Wed Oct 22, 2014 6:33 pm
by srvet_claudio
kcarmody wrote: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;" onclick="window.open(this.href);return false;

Kevin
Thanks Kevin for report the bug and fix.

Re: Richedit justify and numbering style bugs and fixes

Posted: Thu Oct 23, 2014 3:26 am
by Javier Tovar
Muy bien Kevin, Gracias por ver los errores y contribuir en su corrección.
Bienvenido a HMG.
Saludos desde México.

Re: Richedit justify and numbering style bugs and fixes

Posted: Tue Oct 28, 2014 12:05 pm
by bpd2000
Hi Mr. Kevin
Welcome from India
Than you for your contribution